Usage of MySQL load data infile

Source: Internet
Author: User

First create a table
Use test;
Create Table tabletest (
'Id' mediumint (8) default '0 ',
'Name' varchar (100) default''
) Type = MyISAM;

Import data to a data table
Load data infile 'C:/data.txt 'into Table 'tabletest'

Commonly used:
Load data infile 'C:/data.txt 'into table' tabletest' lines terminated by '\ r \ n ';
In this statement, fields are separated by tabs by default. Each record is separated by line breaks. In Windows, the line breaks are \ r \ n"

The content of the C:/data.txt file is shown in the following two lines:
1
2 B
There is a TAB between "1" and ""
In this way, two records are imported.

Custom syntax
Load data infile 'C:/data.txt 'into table' tabletest' fields terminated by ', 'enabled' "'elasticed' by'" 'Lines terminated by '\ r \ n ';

Fields terminated by ', 'enabledby' "'escaped '"'
Each field is separated by a comma. The content is included in double quotation marks.

Lines terminated by '\ r \ n ';
Indicates that each piece of data is separated by a line break.

Which is opposite to load data infile?
Select * From 'tabletest' into OUTFILE 'C:/data_outfile.txt ';
Export table data

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.