[英]Change a mySQL Column datatype from text to timestamp
How can I change the datatype of a column from text to timestamp. 如何将列的数据类型从文本更改为时间戳。 The current text column is storing dates in the format : '2010-08-15' (yyyy-mm-dd sql format) 当前文本列以以下格式存储日期:'2010-08-15'(yyyy-mm-dd sql格式)
ALTER TABLE `mydb`.`mytable` MODIFY COLUMN `mycol` TIMESTAMP;
Using the above command a value such as: 使用上面的命令,例如:
'2010-08-15'
will change to 将改为
TIMESTAMP '2010-08-15 00:00:00'
Have you tried this 你试过这个吗?
alter table table_name change field_name field_name timestamp;
where table_name
is the name of the table and field_name
is the name of the field that you wanted alter the type of. 其中table_name
是表的名称, field_name
是您想要更改其类型的字段的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.