MySQL RENAME Command

Source: Internet
Author: User

MySQL Command rename the renametable syntax renametabletbl_nametonew_tbl_name [, tbl_name2tonew_tbl_na.

 

MySQL Command rename table syntax

Rename table tbl_name to new_tbl_name [, tbl_name2
New_tbl_name2,...]
Renaming is performed in atomic mode (atomically), which means that the table cannot be modified by any other thread when the renaming is running. This makes it possible to replace a table with an empty table.

Create Table new_table (...);
Rename table old_table to backup_table, new_table to old_table;
Rename is executed from left to right, which means that if you want to swap two table names, you have to do this:

Rename table old_table to backup_table,
New_table to old_table,
Backup_table to new_table;
As long as the two databases are on the same disk, you can change the name of one database to another:

Rename table current_db.tbl_name to other_db.tbl_name;
When you execute rename, you cannot have any locked table or activity transactions. You must also have the alter and drop permissions for the original table and the create and insert permissions for the new table.

If MySQL encounters any error in renaming multiple tables, it will rename all renamed tables and return everything to the initial state.

Rename table is added to MySQL 3.23.23.

Reprinted please note this article address: http://www.1366.me/xgjc/sjk_33_371.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.