MySQL – Change Column type to DATETIME with TimeStamp

mysql-tutorials

How to change existing database table column to AUTO DATE TIME field & Value.

Simple command to change the existing column to AUTO TIME STAMP

Syntax :-

ALTER TABLE `<TABLE NAME>`
CHANGE COLUMN `<COLUMN NAME>` `<COLUMN NAME`

TIMESTAMP

NOT NULL

DEFAULT ‘0000-00-00 00:00:00’

Example

ALTER TABLE `stockTr`
CHANGE COLUMN `createdDate` `createdDate` TIMESTAMP NOT NULL DEFAULT ‘0000-00-00 00:00:00’

Related posts

Leave a Comment