从CSV导入14位时间戳到MySQL,避免剥离数据

问题描述:

我正在创建一个mySQL数据库,该数据库将包含其数据时间戳.这些时间戳将从一个如下所示的CSV文件中导入-20110701083231

I'm creating a mySQL db that will contain as part of its data, timestamps. These timestamps will be imported from a CSV file in which they appear like this - 20110701083231

我的问题是将这些数据存储为的最佳数据类型是什么?

My question is which is the best datatype to store these as?

到目前为止,在我的尝试中,在导入过程中(我通过PHPMyAdmin执行),时间戳记的末尾似乎被剥夺了,它们变为2011070000000.

In my attempts so far, during the import process (which I am doing via PHPMyAdmin) the end of the timestamp appears to get stripped out and they become 2011070000000.

奇怪的是,当我返回CSV文件时,那里的条目似乎也以相同的方式被剥夺了??

Oddly, when I return to the CSV file, the entries there also appeared to be stripped out in the same way...?

在此感谢您所散发出的光芒以及以前给予的所有帮助.

Thanks in advance for any light you shed and for all previous help given.

尝试使用此语句吗?

LOAD DATA INFILE 'yourFile.csv'
INTO TABLE yourTable
(@var1)
SET theColumnWhereItShouldBe = STR_TO_DATE(@var1, '%Y%m%d%H%i%s');

哦,该列的类型应该为datetimetimestamp.

Oh, and the column should be of type datetime or timestamp.