About data input in the database ----------------- SELECT... the inverse operation of LOADDATAINFILE in INTOOUTFILE. we generally use insertintotable_namevalues (); to add records to the data table. this is a method. of course, you can also use the mysqlimport utility to load data files. in fact, it also sends l
About data input in the database ----------------- SELECT... INTOOUTFILE's load data infile inverse operation problem. insert into table_name values (); is used to add records to the data table. this is a method. of course, you can also use the mysqlimport utility to load data files. in fact, it also sends l
About data input in the database
------------------- The inverse operation of load data infile in SELECT.
Insert into table_name values (); is used to add records to the data table. this is a method. of course, you can also use the mysqlimport utility to load data files. in fact, it also sends the local data infile command to the server
When inputting a large amount of data, we can use the load data infile syntax.
Previously, we needed to edit a text file and input our data.
The load data infile syntax is as follows:
Load data [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt '[REPLACE | IGNORE] into table tbl_name
[FIELDS
[Terminated by '\ T'] (' \ T' is a tab)
[[OPTIONALLY] enclosed by ''] description is not included in any character.
[Escaped by '\'] indicates that no escape character exists.
]
[Lines terminated by '\ n'] This is also its default status.
[IGNORE number LINES]
[(Col_name,...)]
Note: When the local keyword is not specified, the file must be on the server. when local is specified, files can be read from the client. (in MySQL 3.23.49 and MySQL 4.0.2, only when you do not start mysqld with the -- local-infile = 0 option, or you have not disabled your client program to support LOCAL, LOCAL will work, Prior to MySQL 3.23.24, cannot be read using load data infile)
When reading data from the service, we need to know the following three problems:
1. If it is given as a relative path, such as "./*. txt", this directory is the data directory relative to the server.
2. If "*. txt" is used, the file is read from the current database directory.
3. It is the complete path, that is, the absolute path!
The following fields clause always reports an error at the beginning of input. the reason is that I do not have a clear understanding of fields options. The terminated by char specifies a character to mark the columns to be separated. while enclosed
By char indicates the characters in the column value. the last escaped by char represents the escape character used to escape special characters. the reason for the error was that I was not clear about the default conditions of the three. the above syntax section lists their default conditions. see.
In addition, when you use SELECT... into outfileload data infile and load data infile to output files and read records at the same time, you must note that the fields and row processing options of the two commands must match.
Possible problems are as follows:
Data truncation: data truncated for column 'id' at row 3
This problem occurs when you have not figured out the mysql DATA type. We recommend that you take a look at the data type of the SQL language first. the truncation (disconnection) problem will not occur after the problem is clarified.
(Responsible editor: Ming mingming_ky@126.com TEL :( 010) 68476636)