mysql - Error 1067 for Default of Timestamp column where there is no Default -
i'm having trouble populating schema in mysql 5.5. each table has "create_time" , "update_time" timestamps. prefer have no default these columns 1067 error referencing default value when there no default value.
#1067 - invalid default value 'update_time'
below portion of script generated 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,allow_invalid_dates'; create schema if not exists `database` default character set utf8 collate utf8_general_ci ; use `database` ; create table if not exists `database`.`table` ( `id` int unsigned not null auto_increment, `create_time` timestamp not null, `update_time` timestamp not null, primary key (`id`), unique index `id_unique` (`id` asc)) engine = innodb; set sql_mode=@old_sql_mode; set foreign_key_checks=@old_foreign_key_checks; set unique_checks=@old_unique_checks;
how can create table these timestamps?
from mysql documentation:
as of mysql 5.6.5, timestamp , datetime columns can automatically initializated , updated current date , time (that is, current timestamp). before 5.6.5, true timestamp, , @ 1 timestamp column per table. following notes first describe automatic initialization , updating mysql 5.6.5 , up, differences versions preceding 5.6.5.
since using 5.5 , attempting set both attributes timestamp data type, guaranteed 1 attribute set default value.
this makes sense, because update
column throwing error, second attribute initialized, not allowed generate default timestamp per docs.
Comments
Post a Comment