新建一个SQL,创建一个表
use demo;
create table seckill (
seckill_id bigint NOT NULL AUTO_INCREMENT COMMENT '商品库存id',
name varchar(120) NOT NULL COMMENT '商品名称',
number int NOT NULL COMMENT '库存数量',
start_time timestamp NOT NULL COMMENT '秒杀开启时间',
end_time timestamp NOT NULL COMMENT '秒杀结束时间',
create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP 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='秒杀库存表';
然后继续添加数据:
insert into
seckill(name,number,start_time,end_time)
values
('100秒杀iphone9',100,'2018-8-1 00:00:00','2018-9-1 00:00:00'),
('200秒杀iPad',200,'2018-8-1 00:00:00','2018-11-1 00:00:00'),
('300秒杀小米8',300,'2018-8-1 00:00:00','2018-11-1 00:00:00'),
('400秒杀小米笔记本电脑',400,'2018-8-1 00:00:00','2018-11-11 00:00:00');