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.