MySQL table replication

Source: Internet
Author: User

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>

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.