MySQL CSV导入不插入0

时间:2013-02-03 22:51:41

标签: mysql phpmyadmin

我正在尝试使用phpmyadmin导入CSV格式的.txt文件。它是美国的ZipCode数据库。当我选择导入选项然后加载文件时,除了以0开头的ZipCodes之外,所有内容都会成功插入。它不会添加0所以例如ZipCode 00601获取添加为60101234添加为1234。有没有人以前经历过这种情况或知道预防这种情况的方法?我在下面添加了.txt文件的片段。

段:

"00601","+18.165273","-066.722583","ADJUNTAS","PR","ADJUNTAS","STANDARD"
"00602","+18.393103","-067.180953","AGUADA","PR","AGUADA","STANDARD"
"00603","+18.455913","-067.145780","AGUADILLA","PR","AGUADILLA","STANDARD"
"00604","+18.493520","-067.135883","AGUADILLA","PR","AGUADILLA","STANDARD"

1 个答案:

答案 0 :(得分:1)

您可能将ZipCode数据类型设置为Integer,这就是省略前导零的原因。将ZipCode数据类型更改为char(5),如下所示: Mysql Datatype for US Zip (Postal Codes)