mercredi 24 juin 2015

MySQL Error : Invalid default value for 'CREATED_DATE'

I have created an LAMP instance in AWS and while creating DB, I am stuck with this error

Error Code: 1067. Invalid default value for 'CREATED_DATE'

I checked sql mode and here is the response

 mysql>  SHOW VARIABLES LIKE 'sql_mode';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_mode      |       |
+---------------+-------+

1 row in set (0.00 sec)

I am not sure whey this is happening. Here is my db script

CREATE TABLE ENTITIES (
  ENTITY_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  NAME VARCHAR(30) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
  CREATED_DATE DATETIME DEFAULT CURRENT_TIMESTAMP,   
  UPDATED_DATE DATETIME ON UPDATE CURRENT_TIMESTAMP,     
  INDEX idx_ENTITIES_id1 (ENTITY_ID ASC)
) 
ENGINE = InnoDB
AUTO_INCREMENT=100
;

Any idea on how to fix this?




Aucun commentaire:

Enregistrer un commentaire