MySQL CREATE table

Source: Internet
Author: User

----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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.