Table replication in MySQL: createtablelike and createtableasselect_MySQL

Source: Internet
Author: User
This article mainly introduces table replication in MySQL: createtablelike and createtableasselect. For more information, see the following code:


In this way, when Table B is copied to table A, the complete field structure and indexes of Table B are copied to table.

The code is as follows:

Create table a as select x, xx from B LIMIT 0

This method only copies the field structure of Table B to table A, but does not copy the index of Table B to table. This method is flexible. you can specify the fields to be copied while copying the structure of the original table. you can also add the field structure as needed to copy the table.

Both methods do not copy the permission settings when copying a table. For example, if you have set permissions for Table B, after copying, table A does not have permissions similar to table B.

Leave it blank. next we will discuss the performance of the two types of replication tables.

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