我有一个名为TAG的MySQL表,它从CSV文件中导入值。
mysql> describe TAG;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| TA_BO_ISBN | varchar(14) | YES | | NULL | |
| TA_Tag | varchar(30) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
当我尝试查看整个表时,ISBN编号似乎有问题
mysql> select * from TAG;
+----------------+----------------+
| TA_BO_ISBN | TA_Tag |
+----------------+----------------+
|794557 | paris
|1794558 | france
|1794559 | europe
|94560 | city
|1794561 | lonely
当我选择ISBN号时,结果看起来不错。
mysql> select TA_BO_ISBN from TAG;
+----------------+
| TA_BO_ISBN |
+----------------+
| 978-1741794557 |
| 978-1741794558 |
| 978-1741794559 |
奇怪的是,当我选择标签时,结果再次看起来很奇怪
mysql> select TA_TAG from TAG;
+----------------+
| TA_TAG |
+----------------+
|
|
|
|
|
|
|
|
|
|
|
|untryside
|r
|
|ges
|
这不仅仅是美学,我有一种感觉,这是在我的SQL查询中创建问题。任何人都好奇的导入脚本。
LOAD DATA LOCAL INFILE 'sql/tags.csv'INTO TABLE TAG FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
答案 0 :(得分:0)
要解决此问题,只需将查询更改为:
即可LOAD DATA LOCAL INFILE 'sql/tags.csv'INTO TABLE TAG FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';