5
我是新来的postgres,有时我一直在为Mysql工作。我需要将内容从Mysql表迁移到Postgres表。如何将Mysql时间戳转换为sysdate(6)格式(以毫秒为单位)?
我的Postgres的表是这样的:
Column | Type | Modifiers
--------------------------------+-----------------------------+------------------------------------------------------------------------------------------------
id | integer |
created_at | timestamp without time zone | not null default timezone('UTC'::text, now())
updated_at | timestamp without time zone | not null default timezone('UTC'::text, now())
key_classification | character varying(2000) | not null
我插入created_at和的updated_at从MySQL表,该表的形式为“2014年9月4日23时40分十四秒”的价值。
当我向postgres表中插入一行时,默认时间戳的格式为“2016-01-22 17:44:53.342757”,其中包含时间戳记中的毫秒。
现在我需要将毫秒添加到mysql时间戳格式以匹配postgres表格格式。
请帮助将毫秒添加到时间戳中。
在此先感谢!
也许你需要阅读[时间戳以毫秒presicion如何保存在MySQL(http://stackoverflow.com/questions/26299149/timestamp-with-a-millisecond -precision-how-to-save-them-in-mysql) – eusoj
你需要在mysql中使用这个精度,还是你认为你需要迁移? postgresql也很乐意接受更短的时间戳,即使是“2016-01-22”作为“2016-01-22 00:00:00.000000”的缩写 – knitti