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 fo开发者_高级运维rmat)
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'
Link to documentation.
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.
精彩评论