Answer 01:
CREATE TABLE Dust SELECT * from student;//for replication without creating a new table dust
Answer 02:
INSERT INTO dust SELECT * from student;//has created a new table dust case
Now use Select: Into.. Statement implementation of the above.
MySQL does not support the SELECT INTO statement directly back up the table structure and data, some methods can be replaced, there are other methods can be processed, summarized as follows:
Method 1:
MySQL does not support:
Select * into New_table_name from Old_table_name; This is the usage in SQL Server
Alternative methods:
Create table New_table_name (Select * from Old_table_name);
Method 2:
1. Back up the table structure and data first
#导出命令-u user name-p password-h host IP address database name Table Name 1 > Export file. sql
mysqldump-uroot-proot-h192.168.0.88 ok_db oktable2 > Ok_db.sql
2. Modify the name of the backup table
3. Log in to MySQL
4. Select a database
5. Execute: The path of the source backup table such as: Source D:/ok_db.sql enter.
6. Complete.
MySQL Select into outfile is used to export the specified query data to the following file:
1. Export all the data in the table to the C packing directory Outfile.txt as follows:
Select * into outfile ' c://outfile.txt ' from test;
2. Export the data from the specified query condition 2005-06-08 in the table to the C packing directory Outfile1.txt as follows:
Select * into outfile ' c://outfile.txt ' from test where begindate= ' 2008-06-08 ';
mysql> Load Data local infile "d:/gpsdata.txt" into table positiondata fields terminated by '; ' (Userid,latitude,longitude,altitude,speed,innerid,repo
Rttime,status);
LOAD DATA [low_priority CONCURRENT] [LOCAL] INFILE ' file_name.txt '
[REPLACE IGNORE]
Into TABLE tbl_name
[Fields
[TERMINATED by ' string ']
[[optionally] enclosed by ' char ']
[Escaped by ' char ']
]
[LINES
[Starting by ' string ']
[TERMINATED by ' string ']
]
[IGNORE number LINES]
[(Col_name_or_user_var,...)]
[SET col_name = EXPr,...)]
Fields and lines in front, (Col_name_or_user_var,...) In the back if you use the attributes to write directly after the table name, this is not correct, be sure to write to fields and lines behind!
To add, a table data is copied to table B, B cannot have a self-increment ID
If there is a self-increment ID, the self-increment is not inserted
Insert into B (title) select title from A
SELECT INTO vs. sql in MySQL