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 -
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!