MySQL Forums
Forum List  »  Stored Procedures

Re: No data if queries are issued between TRUNCATE and SELECT INTO
Posted by: irek kordirko
Date: March 26, 2012 04:14PM

Hello,

you can insert records into another table, without truncating the original table,
then 'swap' these two tables using RENAME TABLE, and - at the end - drop renamed original table.

follow this link: http://dev.mysql.com/doc/refman/5.5/en/rename-table.html
Quote

The rename operation is done atomically, which means that no other session can access any of the tables while the rename is running. For example, if you have an existing table old_table, you can create another table new_table that has the same structure but is empty, and then replace the existing table with the empty one as follows (assuming that backup_table does not already exist):
CREATE TABLE new_table (...);
RENAME TABLE old_table TO backup_table, new_table TO old_table;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: No data if queries are issued between TRUNCATE and SELECT INTO
909
March 26, 2012 04:14PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.