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)
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.