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?

WBOY
Release: 2023-09-04 21:49:07
forward
753 people have browsed it

在将文本文件导入 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
Copy after login

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
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template