----Database Initialization Script
---Create a database
CREATE DATABASE Seckill;
---using the database
Use Seckill;
---Create a second kill inventory table
CREATE TABLE Seckill (
' seckill_id ' bigint not NULL auto_increment COMMENT ' commodity stock id ',
' Name ' varchar (+) not NULL COMMENT ' commodity name ',
' Number ' int not NULL COMMENT ' inventory quantity ',
' Start_time ' time not NULL COMMENT ' seconds to kill ',
' End_time ' time not NULL COMMENT ' seconds Kill End ',
' Create_time ' timestamp not NULL DEFAULT current_timestamp COMMENT ' creation time ',
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= ' second kill inventory table ';
--Initialize data
INSERT INTO
Seckill (Name,number,start_time,end_time)
Values
(' 1000 Yuan seconds Kill iphone6 ', ' 100 ', ' 2017-09-26 15:05:35 ', ' 2017-09-27 15:05:44 '),
(' 500 yuan seconds kill ipad2 ', ' 100 ', ' 2017-09-26 15:05:35 ', ' 2017-09-27 15:05:44 '),
(' 200 yuan seconds to kill Xiaomi 4 ', ' 100 ', ' 2017-09-26 15:05:35 ', ' 2017-09-27 15:05:44 '),
(' 100 Yuan seconds to kill red rice note ', ' 100 ', ' 2017-09-26 15:05:35 ', ' 2017-09-27 15:05:44 '),
(' 300 yuan seconds kill Meizu MX6 ', ' 100 ', ' 2017-09-26 15:05:35 ', ' 2017-09-27 15:05:44 ');
----seconds to kill a list of successes
----User Login Authentication Related information
CREATE TABLE success_killed (
' seckill_id ' int not NULL COMMENT ' second kill commodity ID ',
' User_phone ' int not NULL COMMENT ' user phone number ',
' state ' tinyint not NULL DEFAULT-1 COMMENT ' status representation;-1: Invalid 0: Success 1: Paid 2: Shipped 3: Received ',
' Create_time ' timestamp not NULL COMMENT ' creation time ',
PRIMARY Key (Seckill_id,user_phone),/* Federated PRIMARY KEY */
Key Idx_create_time (Create_time)
) Engine=innodb DEFAULT Charset=utf8 comment= ' second kill success List ';
---Connect to the database console
Mysqk-uroot-p
MySQL CREATE table