When you create a table in MySQL, the following questions are encountered on the newly added field time:
The table statement is as follows:
CREATE TABLESeckill (seckill_idbigint not NULLAuto_increment COMMENT'Item Stock ID', namevarchar( -) not NULLCOMMENT'Product Name', Number int not NULLCOMMENT'Inventory Quantity', Start_timetimestamp not NULLCOMMENT'seconds kill turn on time', End_timetimestamp not NULLCOMMENT'seconds to kill end time', Create_timetimestamp not NULL DEFAULT Current_timestampCOMMENT'creation Time',PRIMARY KEY(seckill_id),KeyIdx_start_time (start_time),KeyIdx_end_time (end_time),Keyidx_create_time (Create_time)) ENGINE=InnoDB auto_increment= +COMMENT='seconds to kill inventory table';
Execute the above statement and return the error:
Incorrect table definition; There can is only one TIMESTAMP column with the Current_timestamp in DEFAULT or on UPDATE clause.
The MySQL version I am using is 5.5. Query for the reason:
Changes in MySQL 5.6.5 (2012-04-10, Milestone 8)
Previously, at most one TIMESTAMP column per table could is automatically initialized or updated to the current date and T Ime. This restriction has been lifted. Any TIMESTAMP column definition can has any combination of the DEFAULT current_timestamp and on UPDATE current_timestamp Clau Ses. In addition, these clauses now can is used with DATETIME column definitions. For more information, see Automatic Initialization and Updating for TIMESTAMP and DATETIME.
This means: Timestamp does not add the default value, and the build table statement is changed to:
CREATE TABLESeckill (seckill_idbigint not NULLAuto_increment COMMENT'Item Stock ID', namevarchar( -) not NULLCOMMENT'Product Name', Number int not NULLCOMMENT'Inventory Quantity', Start_timetimestamp DEFAULT 0 not NULLCOMMENT'seconds kill turn on time', End_timetimestamp DEFAULT 0 not NULLCOMMENT'seconds to kill end time', Create_timetimestamp not NULL DEFAULT Current_timestampCOMMENT'creation Time',PRIMARY KEY(seckill_id),KeyIdx_start_time (start_time),KeyIdx_end_time (end_time),Keyidx_create_time (Create_time)) ENGINE=InnoDB auto_increment= +COMMENT='seconds to kill inventory table';
You can create a success.
MySQL new expression, Time field Timetamp encountered problems