将MySQL TIMESTAMP转换为DATETIME时出错

时间:2011-11-06 09:56:52

标签: mysql

我有一个表(example_table_1),其时间戳列声明如下:

`ts1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

此MySQL语句生成语法错误:

CREATE TABLE example_table_2 AS
SELECT DATETIME(ts1)
FROM example_table_1

如何让我的第二个表将TIMESTAMP数据作为DATETIME列?

1 个答案:

答案 0 :(得分:2)

create table example_table_2 as
select cast(ts1 as datetime) as ts1
from example_table_1