//data.txt为:"0001","大学英语","1001","12",
"0002","高等数学","1002","6",
"0003","马克思主义哲学","1003","2",
"0004","邓小平理论","1004","2",用load语句导入到course表中出现了下面的状况:
mysql> select * from course;
+------+-----------------------+------+---------+
| cno | cname | cpno | ccredit |
+------+-----------------------+------+---------+
| " | 大学英语 | 1001 | 12 |
| 0002 | 高等数学 | 1002 | 6 |
| 0003 | 马克思主义哲学 | 1003 | 2 |
| 0004 | 邓小平理论 | 1004 | 2 |
+------+-----------------------+------+---------+
4 rows in set (0.00 sec)我建立的course表结构是这样的:
mysql> create table course
-> (
-> cno char(4) primary key,
-> cname char(40),
-> cpno char(4),
-> ccredit smallint
-> );
Query OK, 0 rows affected (0.14 sec)不知道,为什么第一行的cno会变成 " ?warning 信息是:
| Warning | 1265 | Data truncated for column 'cno' at row 1 |
| Warning | 1262 | Row 1 was truncated; it contained more data than there were input columns |
| Warning | 1262 | Row 2 was truncated; it contained more data than there were input columns |
| Warning | 1262 | Row 3 was truncated; it contained more data than there were input columns |
+---------+------+---------------------------------------------------------------------------+
4 rows in set (0.00 sec)
"0002","高等数学","1002","6",
"0003","马克思主义哲学","1003","2",
"0004","邓小平理论","1004","2",用load语句导入到course表中出现了下面的状况:
mysql> select * from course;
+------+-----------------------+------+---------+
| cno | cname | cpno | ccredit |
+------+-----------------------+------+---------+
| " | 大学英语 | 1001 | 12 |
| 0002 | 高等数学 | 1002 | 6 |
| 0003 | 马克思主义哲学 | 1003 | 2 |
| 0004 | 邓小平理论 | 1004 | 2 |
+------+-----------------------+------+---------+
4 rows in set (0.00 sec)我建立的course表结构是这样的:
mysql> create table course
-> (
-> cno char(4) primary key,
-> cname char(40),
-> cpno char(4),
-> ccredit smallint
-> );
Query OK, 0 rows affected (0.14 sec)不知道,为什么第一行的cno会变成 " ?warning 信息是:
| Warning | 1265 | Data truncated for column 'cno' at row 1 |
| Warning | 1262 | Row 1 was truncated; it contained more data than there were input columns |
| Warning | 1262 | Row 2 was truncated; it contained more data than there were input columns |
| Warning | 1262 | Row 3 was truncated; it contained more data than there were input columns |
+---------+------+---------------------------------------------------------------------------+
4 rows in set (0.00 sec)
load data local infile '/home/kuzuozhou/桌面/data.txt' into table course fields terminated by ',' enclosed by '"' lines terminated by '\n';
UTF格式我注意了啊。。
问题解决了就结贴给分!
这是我的风格!