如何将Mysql时间戳转换为sysdate(6)格式(毫秒)?

如何将Mysql时间戳转换为sysdate(6)格式(毫秒)?,mysql,postgresql,timestamp,Mysql,Postgresql,Timestamp,我是postgres的新手,有时我一直在安静地使用Mysql。我需要将内容从Mysql表迁移到Postgres表 我的Postgres表如下所示: Column | Type | Modifiers ----------------

我是postgres的新手,有时我一直在安静地使用Mysql。我需要将内容从Mysql表迁移到Postgres表

我的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
我正在从mysql表中插入创建的_at和更新的_at值,格式为“2014-09-04 23:40:14”

当我在postgres表中插入一行时,默认时间戳的格式为“2016-01-22 17:44:53.342757”,时间戳中包含毫秒

现在我需要将毫秒添加到mysql时间戳格式中,以匹配postgres表格式

请帮助将毫秒添加到时间戳中

提前谢谢

早上好 我希望这有帮助

我正在运行Mysql/MariaDB

MariaDB [(none)]> SHOW VARIABLES LIKE "%version%";
+-------------------------+-----------------+
| Variable_name           | Value           |
+-------------------------+-----------------+
| innodb_version          | 5.6.25-73.1     |
| protocol_version        | 10              |
| slave_type_conversions  |                 |
| version                 | 10.0.21-MariaDB |
| version_comment         | MariaDB Server  |
| version_compile_machine | x86_64          |
| version_compile_os      | Linux           |
| version_malloc_library  | system          |
+-------------------------+-----------------+
8 rows in set (0.00 sec)
我在引用 哪个是mysql版本5.7

运行示例

As mysql Admin 
mysql -u USERNAME -p

CREATE USER 'test'@'localhost' IDENTIFIED BY 'test';

CREATE DATABASE test;

GRANT ALL ON test.* TO 'test'@'localhost';
退出,然后作为测试登录

mysql -u test -p
密码是test

然后

插入的值是要插入mysql的时间戳格式。


最好的

也许您需要阅读mysql中是否需要这种精度,或者您只是认为迁移需要这种精度?postgresql也乐于接受更短的时间戳,甚至“2016-01-22”也可以作为“2016-01-22 00:00:00.000000”的缩写
CREATE TABLE test.td6(ts6 timestamp(6));

INSERT INTO test.td6 VALUES ('2016-01-22 17:44:53.342757');