MySQL table replication
MySQL server doesn't support the select... into Table Sybase SQL extension. instead, MySQL serversupports the insert... select standard sqlsyntax, which is basically the same thing. // Official Document Description
MySQL does not support select... Into syntax, USE insert... Select Replace the same usage. The following are two table replication methods:
1. The table does not have a copy.
Mysql> show tables; + --------------- + | tables_in_test1 | + ----------------- + | cpu_stat | test1 | Test2 | test3 | + ----------------- + 4 rows in SET (0.02 Sec) mysql> Create tabletest4 as select * From test1 where 1 = 0; // only copy the table structure queryok, 0 rows affected (0.06 Sec) records: 0 duplicates: 0 Warnings: 0 mysql> Create tabletest5 as select * From test1; // copy all contents of table test1 to test5queryok, 7 rows affected (0.11 Sec) records: 7 duplicates: 0 Warnings: 0 mysql>
2. the table has been copied.
Mysql> Create Table test6 (ID int not null auto_increment primary key, name varchar (20); query OK, 0 rows affected (0.13 Sec) mysql> insert into test6 (name) select name from test1; // only copy the name column query OK, 7 rows affected (0.06 Sec) records: 7 duplicates: 0 Warnings: 0 mysql> select * From test6; + ---- + ------- + | ID | Name | + ---- + ------- + | 1 | Wu | 2 | Terry | 3 | Tang | ...... 7 rows in SET (0.00 Sec) mysql>