How to updat a whole table

    I have a requirement, updating a whole table, and the content of the table would be quite different sometimes. I came up with the following steps to update it.

    Step1. Check if the table exists, if yes, drop the table.
    Step2. Create a new table and put the latest data into the table.

   However, I am afraid that these two steps are not atomic, which means it might raise an error if step1 is done successfully, and fail to execute step 2. I was just wondering if there is any method to make these two steps as an atomic operation. Or any method to rollback the result of step1 if step2 is failed. If there's any other suggestion, please kindly let me know.

    Thanks in advance for your help!

请先 登录 后评论

最佳答案 2022-11-25 15:26

Currently these two steps are not atomic. The solution to your problem is to create a new table with a different name 

and write data into the table, then delete the old table, and then rename the new table after the deletion is successful. 

However, the rename function only supports non-shared memory tables and OLAP engine distributed tables.

If you encounter any issues, feel free to contact us. And we encourage you to join our slack channel at 

https://join.slack.com/t/dolphindb/shared_invite/zt-1e9w27dfl-3W2hYVIU4~HTfhCF4pE1Dg. There we have other users 

and support engineers who will answer your questions.

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,780 浏览
  • Alex 提出于 2022-11-23 09:47