For MySQL to replicate the same table structure method, there are create table as and create table like two kinds, what is the difference?
CREATE TABLE t2 as SELECT * from T1 where 1=2;
or limit 0;
The T2 table (the new table) created by as is missing the index information for the T1 table (source table), with only the same table structure and no indexes.
CREATE table t2 like T1;
The new table created by like contains the full table structure and index information for the source table.
The use of the two:
As is used to create the same table structure and copy the source table data.
Like is used to create a full table structure and all indexes.
Oracle supports as, and only the table structure is not indexed, and Oracle does not support like.
There are two ways to copy a table without copying the permissions on the table settings. For example, the permissions set for Table B, after replication, table A does not have permissions similar to Table B.
MySQL copy table structure the difference between create table as and like