The difference between select INTO and MSSQL SELECT into usage in MySQL

Source: Internet
Author: User
Tags mssql one table

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;
Related Article

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.