Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDL issue #30

Open
zyshengcoding opened this issue Dec 4, 2018 · 0 comments
Open

DDL issue #30

zyshengcoding opened this issue Dec 4, 2018 · 0 comments

Comments

@zyshengcoding
Copy link

CREATE TABLE seckill(
seckill_id BIGINT NOT NUll AUTO_INCREMENT COMMENT '商品库存ID',
name VARCHAR(120) NOT NULL COMMENT '商品名称',
number int NOT NULL COMMENT '库存数量',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
start_time TIMESTAMP NOT NULL COMMENT '秒杀开始时间',
end_time TIMESTAMP NOT NULL COMMENT '秒杀结束时间',
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='秒杀库存表';
--把 create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP 这条语句放在start_time 前面,
--原因是mysql会默认为表中的第一个timestamp字段(且设置了NOT NULL)隐式设置DEFAULAT CURRENT_TIMESTAMP。
-- 所以默认的顺序设置实际上等同于设置了两个CURRENT_TIMESTAMP,因此而报错,调整之后就可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant