![]() ![]() the table is automatically reopened by the next statement that accesses it. If you are able to execute a FLUSH TABLES table_name statement and have it return within a few seconds, that should serve as confirmation that the rename operation will complete in a similar amount of time, since it will need the same locks in order to remove any entries in the query cache related to the table, close the table, and clean up some internal structures like the table share object. The major delay you could see will come from other sessions preventing the RENAME from starting because the locks can't be immediately required. ![]() Note that's a link to the 5.0 documentation, and the 5.1, 5.5, 5.6, and 5.7 all have the same information. If you use ALTER TABLE tbl_name RENAME TO new_tbl_name without any other options, MySQL simply renames any files that correspond to the table tbl_name without making a copy. Renaming a table acquires a metadata lock on the table which requires that no statements be running against the table, no transactions have row locks, and no transactions are holding on to consistent snapshots of any MVCC versions of the table.Įither style of RENAME operation will attempt to acquire the metadata lock and subsequently-started statement impacting the table will block, waiting for the pending metadata lock. RENAME TABLE t1 TO t2 ĪLTER TABLE t1 RENAME TO t2 # as long as no other options to ALTER are also specified There are two statements that perform an equivalent operation. ![]() Renaming a table in MySQL does not require a temporary table. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |