I have a large .txt file including 20 millions of lines of strings like:
"CS1221|123.10|17.02.2012 09:10:23,5676"
The first is customer id, then separated by "|" we have $ amount of transactions and finally date and time (dd.mm.yyyy hh:mm:ss,ssss).
I am trying to load it to Mysql table but it isn't accepting this ordering as TIMESTAMP
(it accepts YYYY-MM-DD hh:mm:ss,ssss)
Is there any piece of code written in mysql that helps me?
You can use the STR_TO_DATE method to convert that date format. Try something like this:
SELECT STR_TO_DATE('17.02.2012 09:10:23,5676', '%d.%m.%Y %H:%i:%s,%f');
Should yield:
2012-02-17 09:10:23.567600
So your INSERT query would look something like:
INSERT INTO your_table (all, relevant, field_names) VALUES ("CS1221", "123.10", STR_TO_DATE('17.02.2012 09:10:23,5676', '%d.%m.%Y %H:%i:%s,%f'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.