teelou teelou - 25 days ago 13
SQL Question

MySQL workbench to PHPMyAdmin: 0000-00-00 00:00:00 - Invalid default value

Why do I get an error message when I import SQL created MySQL workbench?

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;

SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';





-- -----------------------------------------------------

-- Table `$type`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `type` (

`type_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,

`name` VARCHAR(255) NULL DEFAULT NULL ,

`created_on` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ,

`updated_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,

PRIMARY KEY (`type_id`) )

ENGINE = MyISAM

AUTO_INCREMENT = 1

DEFAULT CHARACTER SET = utf8;



SET SQL_MODE=@OLD_SQL_MODE;

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;


error message,

#1067 - Invalid default value for 'created_on'


What is wrong with this value -
0000-00-00 00:00:00

Answer

Use DATETIME instead of TIMESTAMP

Comments