Import data from the text file into the MySQL database

Source: Internet
Author: User

Title, import the data from the text file into the MySQL database.
My own specific implementation can be divided into several:
1, write your good programming language to read and write files, and then connect to the database, write;
2. Run SQL script statements directly in MySQL and import them.

The first one is now no longer said, simple.
Let's talk about how to import the. text file directly from the SQL statement.
1. First create a new table in the database (the table here must match the field in your data, that is, the number of fields that exist on a row);
2. Run the SQL script statement:
For example: your file is d:/field.txt; The database table name is field; The field in the text file is separated by a tab (\ t);
LOAD DATA INFILE ' d:/field.txt ' into TABLE field fields TERMINATED by ' \ t ' LINES TERMINATED by ' \ n '
Click Execute to get the data.
New post table count is 0

After running the MySQL script statement

Import data Count

This is recorded for later needs.

Import data from the text file into the MySQL database

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.