單表多timestamp報(bào)錯(cuò)#1293 -?Incorrect table definition; there can be only one TIMESTAMP column with C解決 ? 一個(gè)表中出現(xiàn)多個(gè)timestamp并設(shè)置其中一個(gè)為current_timestamp的時(shí)候經(jīng)常會(huì)遇到 #1293 - Incorrect table definition; there can be only oneTIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATEclause ? www.2cto.com ? 原因是當(dāng)你給一個(gè)timestamp設(shè)置為on updatecurrent_timestamp的時(shí)候,其他的timestamp字段需要顯式設(shè)定default值 ? 但是如果你有兩個(gè)timestamp字段,但是只把第一個(gè)設(shè)定為current_timestamp而第二個(gè)沒(méi)有設(shè)定默認(rèn)值,mysql也能成功建表,但是反過(guò)來(lái)就不行... ??
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause,出現(xiàn)多個(gè)timestamp就會(huì)出錯(cuò)
2016-05-09
--數(shù)據(jù)庫(kù)初始化腳本
--創(chuàng)建數(shù)據(jù)庫(kù)
CREATE DATABASE seckill
use seckill
--創(chuàng)建秒殺庫(kù)存表
CREATE TABLE seckill(
seckill_id bigint NOT NULL AUTO_INCREMENT COMMENT '商品庫(kù)存id',
name varchar(120) NOT NULL COMMENT '商品名稱',
number int NOT NULL COMMENT '庫(kù)存數(shù)量',
start_time timestamp NOT NULL COMMENT '秒殺開始時(shí)間',
end_time timestamp NOT NULL COMMENT '秒殺結(jié)束時(shí)間',
create_time TIMESTAMP NOT NULL DEFAULT ?CURRENT_TIMESTAMP ?COMMENT '創(chuàng)建時(shí)間',
PRIMARY KEY (seckill_id),
key idx_start_time(start_time),
key idx_end_time(end_time),
key idx_create_time(create_time)
)ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 COMMENT='秒殺庫(kù)存表'
--初始化數(shù)據(jù)
insert into
? ?seckill (name , number , start_time , end_time)
VALUES
? ?('100元秒殺ipad' , 100 , '2015-11-01 00:00:00' , '2015-11-02 00:00:00'),
? ?('200元秒殺小米5' , 100 , '2015-11-01 00:00:00' , '2015-11-02 00:00:00'),
? ?('300元秒殺iphone6s' , 100 , '2015-11-01 00:00:00' , '2015-11-02 00:00:00');
--秒殺成功明細(xì)
--用戶登錄認(rèn)證信息
create table success_seckilled(
seckill_id bigint NOT NULL ?COMMENT '商品庫(kù)存id',
phone varchar(11) NOT NULL COMMENT '用戶電話',
state tinyint NOT NULL DEFAULT ?0 COMMENT '狀態(tài)標(biāo)識(shí):-1:無(wú)效 0:成功 1:已付款 2:已發(fā)貨',
create_time TIMESTAMP ?NOT NULL COMMENT '創(chuàng)建時(shí)間',
PRIMARY KEY (seckill_id , phone) , /*聯(lián)合主鍵*/
key idx_create_time(create_time)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='秒殺成功明細(xì)'
2017-04-24
CREATE TABLE seckill(
seckill_id bigint NOT NULL AUTO_INCREMENT COMMENT '商品庫(kù)存id',
`name` varchar(120) NOT NULL COMMENT '商品名稱',
`number` int NOT NULL COMMENT '庫(kù)存數(shù)量',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '創(chuàng)建時(shí)間',
`start_time` timestamp NOT NULL COMMENT '秒殺開始時(shí)間',
`end_time` timestamp NOT NULL COMMENT '秒殺結(jié)束時(shí)間',
PRIMARY KEY (seckill_id),
key idx_start_time(start_time),
key idx_end_time(end_time),
key idx_create_time(create_time)
)ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 COMMENT='秒殺庫(kù)存表';
單表多timestamp報(bào)錯(cuò)#1293 -?Incorrect table definition; there can be only one TIMESTAMP column with C解決 ? 一個(gè)表中出現(xiàn)多個(gè)timestamp并設(shè)置其中一個(gè)為current_timestamp的時(shí)候經(jīng)常會(huì)遇到 #1293 - Incorrect table definition; there can be only oneTIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATEclause ? www.2cto.com ? 原因是當(dāng)你給一個(gè)timestamp設(shè)置為on updatecurrent_timestamp的時(shí)候,其他的timestamp字段需要顯式設(shè)定default值 ? 但是如果你有兩個(gè)timestamp字段,但是只把第一個(gè)設(shè)定為current_timestamp而第二個(gè)沒(méi)有設(shè)定默認(rèn)值,mysql也能成功建表,但是反過(guò)來(lái)就不行... ??
? ?
2016-09-30
AUTO_INCREMENT=1000這里設(shè)置成1000是什么意思
2016-06-27
1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
mysql>?
2016-05-07
報(bào)什么錯(cuò),貼出來(lái)大家?guī)湍阏摇?/p>