Import the data in the text file to the mysql database.

Source: Internet
Author: User

Import the data in the text file to the mysql database.

For example, import the data in the text file to the mysql database.
My own implementations can be divided into several types:
1. Write the programming language you are good at to read and write files, connect to the database, and write;
2. Run the SQL script statement in mysql for import.

The first one will not be mentioned now. It is simple.
Now let's talk about how to directly import the. text File Using SQL statements.
1. First, create a new table in the database (the table here must at least match the fields in your data, that is, the number of fields in a row );
2. Run the SQL script statement:
For example, your file is D:/field.txt; the database table name is field; the fields in the text file are separated by tabs (\ t;
Load data infile 'd:/field.txt 'into table field fields terminated by '\ t' lines terminated by' \ N'
Click execute to obtain the data.
After the table is created, the count value is 0.

After running the mysql script statement

Import Data count

Record here for future use.

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.