How to move and rename a data table in MySQL

Source: Internet
Author: User

This article briefly introduces some common commands for MySQL to move and rename data tables.

What should I do if I want to migrate the MySQL Table to another database, rename the Table, and change the names of the two tables?


How to migrate and rename a Table in MySQL

All commands can be achieved by using RENAME,


MySQL Table to be migrated from db_a to db_ B

The Code is as follows: Copy code

Rename table db_a.old_table TO db_ B .new_table;

Change MySQL Table name (rename)

The Code is as follows: Copy code

Rename table old_table TO new_table;

The names of two tables in MySQL must be replaced.

The Code is as follows: Copy code

Rename table old_table TO tmp_table,
New_table TO old_table,
Tmp_table TO new_table;

Related Article

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.