Table replication in MySQL: create table like and create table as select, tables in mysql

Source: Internet
Author: User

Table replication in MySQL: create table like and create table as select, tables in mysql

Copy codeThe Code is as follows:
CREATE TABLE A LIKE B

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

Copy codeThe 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.

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.