MySQL database using SQL command Window query data, changed to SQL statement imported into MySQL database

Source: Internet
Author: User

1. The query statement is select * from t_table; The exported data format is as follows:

2. Back up the data text, then open it using notepad++, then copy the data to the new TXT and replace it as follows:

1) will "| "Delimiter (delimiter of different fields), replace with ', ' is the delimiter of the different fields in the SQL statement;

2) Leave the leftmost "|" For each row of data "Replace with (') the left parenthesis of each record in the SQL statement;

3) the "|" at the far right of each row of data Replace with '), which is the right parenthesis for each record in the SQL statement;

4) Replace the last row of data with the end of the symbol for the SQL statement;

5) Replace "", no space required;

6) The first line of data is preceded by insert into t_table values, and the data is concatenated together to form the SQL statement.

3. Execute the assembled SQL and modify them if there are any errors.

The assembled SQL statement format is as follows:

Note that each field is treated as a string, and if a field cannot be treated as a string, it needs to be modified accordingly.

But in any case, this one-time insertion, it is more convenient, and high insertion efficiency.

MySQL database using SQL command Window query data, changed to SQL statement imported into MySQL database

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.