mysql 加载和查询显示错误结果
mysql load and query showing wrong results
我正在使用 mysql 服务器版本 5.1.73。
我正在加载此文件:http://delphi.cs.csubak.edu/~wroyer/TGradebook/final/majors.data
我正在使用
加载我的数据
LOAD DATA LOCAL INFILE 'majors.data'
REPLACE
INTO TABLE Majors
FIELDS TERMINATED BY '| ';
当我 运行 查询 SELECT * FROM Majors;
我得到以下输出:
+------+--------------------------------+-------------+
| Code | Major | shortName |
+------+--------------------------------+-------------+
| -1 | Undeclared | Undeclared
| 1 | Computer Science | Comp Sci
| Mathematics | Math
|3 | Pre-Engineering | Pre-Eng
|4 | Physics | Physics
|5 | Geology | Geology
| 6 | Anthropology | Anthropo
|7 | Biology | Biology
| 8 | Chemistry | Chemistry
| 9 | Natural Sciences | Natura Sci
|0 | Nursing | Nursing
|Art | Art
|2 | Communications | Communi
|3 | English | English
| | History | Histry
| 35 | Modern Languages | Modern Lan
|| Music | Music
| 37 | Philosophy | Philosophy
|8 | Theatre | Theatre
| 39 | Religious Studies | Reglig Stu
| 40 | Literatures | Literature
| 50 | Accounting | Accounting
| 51 | Business Administration | Busini Adm
| 52 | Economics | Economics
| 53 | Environmental Resource Mgmt. | EnvRes Mmt
| 54 | Management & Marketing | Mgmt & Mkt
|Management Information Systems | MIS
| 56 | Public Policy Administration | Pub Po Adm
|7 | Finance | Finance
| 70 | Advanced Educational Studies | Adv Edu St
| 71 | Criminal Justice | Crimin Stu
| 72 | Liberal Studies | Liberal St
| 73 | Physical Education | Physicl Ed
| 74 | Political Science | Politi Sci
| 75 | Psychology | Psychology
| 76 | Social Work | Social Wrk
| 77 | Sociology | Sociology
| 78 | Special Education | Special Ed
| 79 | Teacher Education | Teacher Ed
| 80 | Kinesiology | Kinesiolog
| 90 | Seeking Credential | Seek Crede
| 91 | Special Major | Special Mj |
+------+--------------------------------+-------------+
如果我 运行 SELECT * FROM Majors WHERE Code = 2;
我得到:
+------+-------------+-----------+
| Code | Major | shortName |
+------+-------------+-----------+
| | Mathematics | Math
+------+-------------+-----------+
这只是 mysql 格式问题吗?
根据 Windows vs Unix 添加 LINES TERMINATED 和合适的值。
我正在使用 mysql 服务器版本 5.1.73。
我正在加载此文件:http://delphi.cs.csubak.edu/~wroyer/TGradebook/final/majors.data
我正在使用
LOAD DATA LOCAL INFILE 'majors.data'
REPLACE
INTO TABLE Majors
FIELDS TERMINATED BY '| ';
当我 运行 查询 SELECT * FROM Majors;
我得到以下输出:
+------+--------------------------------+-------------+
| Code | Major | shortName |
+------+--------------------------------+-------------+
| -1 | Undeclared | Undeclared
| 1 | Computer Science | Comp Sci
| Mathematics | Math
|3 | Pre-Engineering | Pre-Eng
|4 | Physics | Physics
|5 | Geology | Geology
| 6 | Anthropology | Anthropo
|7 | Biology | Biology
| 8 | Chemistry | Chemistry
| 9 | Natural Sciences | Natura Sci
|0 | Nursing | Nursing
|Art | Art
|2 | Communications | Communi
|3 | English | English
| | History | Histry
| 35 | Modern Languages | Modern Lan
|| Music | Music
| 37 | Philosophy | Philosophy
|8 | Theatre | Theatre
| 39 | Religious Studies | Reglig Stu
| 40 | Literatures | Literature
| 50 | Accounting | Accounting
| 51 | Business Administration | Busini Adm
| 52 | Economics | Economics
| 53 | Environmental Resource Mgmt. | EnvRes Mmt
| 54 | Management & Marketing | Mgmt & Mkt
|Management Information Systems | MIS
| 56 | Public Policy Administration | Pub Po Adm
|7 | Finance | Finance
| 70 | Advanced Educational Studies | Adv Edu St
| 71 | Criminal Justice | Crimin Stu
| 72 | Liberal Studies | Liberal St
| 73 | Physical Education | Physicl Ed
| 74 | Political Science | Politi Sci
| 75 | Psychology | Psychology
| 76 | Social Work | Social Wrk
| 77 | Sociology | Sociology
| 78 | Special Education | Special Ed
| 79 | Teacher Education | Teacher Ed
| 80 | Kinesiology | Kinesiolog
| 90 | Seeking Credential | Seek Crede
| 91 | Special Major | Special Mj |
+------+--------------------------------+-------------+
如果我 运行 SELECT * FROM Majors WHERE Code = 2;
我得到:
+------+-------------+-----------+
| Code | Major | shortName |
+------+-------------+-----------+
| | Mathematics | Math
+------+-------------+-----------+
这只是 mysql 格式问题吗?
根据 Windows vs Unix 添加 LINES TERMINATED 和合适的值。