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!
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.