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