LOADDATALOCALINFILE'd:\A.txt'INTOtableemployee10_tb"/> LOADDATALOCALINFILE'd:\A.txt'INTOtableemployee10_tb">

Home >Database >Mysql Tutorial >When importing a text file into a MySQL table, how does MySQL evaluate blank lines between two lines written in a text file?

When importing a text file into a MySQL table, how does MySQL evaluate blank lines between two lines written in a text file?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBforward
2023-09-04 21:49:07771browse

在将文本文件导入 MySQL 表时,MySQL 如何评估文本文件中写入的两行之间的空白行?

Suppose that if there is a blank line between two lines written in a text file, MySQL will evaluate it as a data row when importing the text file into a MySQL table. It can be understood through the following example -

Example

Suppose we have a blank line between two lines in a text file named "A.txt" as shown below-

105,Chum,USA,11000
106,Danny,AUS,12000

Now we can write the following query to import the data from the text file into the MySQL table -

mysql> LOAD DATA LOCAL INFILE 'd:\A.txt' INTO table employee10_tbl FIELDS TERMINATED BY ',';
Query OK, 3 rows affected, 4 warnings (0.05 sec)
Records: 3 Deleted: 0 Skipped: 0 Warnings: 4

The above query shows that 3 rows have been uploaded and there are 4 warnings. Now, with the help of the following query, we can see what has been uploaded -

mysql> Select * from employee10_tbl;
+------+----------------+----------+--------+
| Id   | Name           | Country  | Salary |
+------+----------------+----------+--------+
| 105  | Chum           | USA      |  11000 |
|   0  | NULL           | NULL     |   NULL |
| 106  | Danny          | AUS      |  12000 |
+------+----------------+----------+--------+
3 rows in set (0.00 sec)

The above result set shows that MySQL is uploading NULL and 0 in the columns as the empty rows between the two rows.

The above is the detailed content of When importing a text file into a MySQL table, how does MySQL evaluate blank lines between two lines written in a text file?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete