MySQL does not support the SELECT INTO statement directly back up the table structure and data, due to the need to find a way on the internet can be replaced, there are other ways to deal with, summed up as follows:
Method 1:
MySQL does not support:
The code is as follows |
Copy Code |
Select * into New_table_name from Old_table_name; Alternate method: Create table New_table_name (Select * from Old_table_name); |
Method 2:
1. Backup table structure and data first
#导出命令-u username-p password-h host IP address database name Table Name 1 > Export file. sql
The code is as follows |
Copy Code |
mysqldump-uroot-proot-h192.168.0.88 ok_db oktable2 > Ok_db.sql |
2. Modify the name of the backup table
3. Login to MySQL
4. Select Database
5. Execution: Source backup table path such as: source D:ok_db.sql carriage return.
6. Complete.
Two. SQL Server supports Select into statement
1. The backup table can be executed directly as follows.
The code is as follows |
Copy Code |
Select * into New_table_name from Old_table_name; |
Three. MySQL Select into outfile is used to export the specified query data to the following file:
1. Export all data in the table to C packing directory Outfile.txt as follows:
The code is as follows |
Copy Code |
Select * into outfile ' c:\outfile.txt ' from test; |
2. The data of the 2005-06-08 number of the specified query conditions in the export table are as follows in the C Packing directory Outfile1.txt:
The code is as follows |
Copy Code |
Select * into outfile ' c:\outfile.txt ' from test where begindate= ' 2008-06-08′; |
3.linux Medium
The MySQL select INTO outfile can export data from one table to a text file
code is as follows |
copy code |
select OutFile '/home/mysql/data.txt ' from the dbstatus.slow_sql order by timestamp; |