I am creating a database table with the following sql:
CREATE TABLE `cs3_ds1` (
`ID` INT NOT NULL ,
`TIME` TIMESTAMP NOT NULL ,
`USER` VARCHAR(45) NOT NULL ,
`TIME1` TIMESTAMP NOT NULL ,
`TIME2` TIMESTAMP NOT NULL ,
`INSERT_TIME` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (`ID`) )
ENGINE = InnoDB
Although I am using the current timestamp as default in one column only, But I am getting the following error:
ERROR 1293: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
why I am getting this error?
MySQL auto initialises TIMESTAMP Columns with
DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, so your first columnTIMEhas the CURRENT_TIMESTAMP Added as default. Therefore by the time you explicitly add a DEFAULT to a column one already exists. You either need to change the order your columns are defined:Or add defaults to your other timestamp columns:
See the MySQL Docs for further information.