database table Common constraints and case references

Source: Internet
Author: User

① PRIMARY KEY constraint Pk_name primary key <column_name>
② FOREIGN KEY constraint fk_name foreign key (COLUMN_NAME) reference table_name (COLUMN_NAME)
③ checking constraint ck_name check (condition)
④ Unique constraint un_name unique (column_name)
⑤ non-empty <column name> <data type> not NULL,
⑥ Default value <column name> <data type> default <default value> --Creating the Train table Create table T_train (Trainnum VARCHAR2 () primary key, Startstation VARCHAR2 (+), Endstation VARCHAR2 (5 0), STARTTIME VARCHAR2 (+), ENDTIME VARCHAR2 (a), TotalTime VARCHAR2 (+), TYPE VARCHAR2 (+), OBJ VARCHAR2 (100))--Create TABLE T_station (Trainnum VARCHAR2 (50),--Train number Startstation VARCHAR2 (50),--Initial account Taiwan endstation VARCHAR2 (50),--End station STARTTIME VARCHAR2 (50),--Start time ENDTIME VARCHAR2 (50),--End time TotalTime VA RCHAR2 (50),--Total time Price FLOAT,--Prices OBJ VARCHAR2 (100),--remark constraint fk_trainnum foreign key (Trainn UM) references T_train (trainnum)--constraint foreign key-associated train table--Create TABLE T_seat (Trainnum VARCHAR2 (+), Seattype VARCHAR2 (50), Seatno VARCHAR2 (), Seatprice FLOAT, Seatstatu INTEGER, OBJ VARCHAR2 (+), constraint T_fk_trainnum Foreign KEY (Trainnum) references T_train (trainnum)--constraint foreign key-associated train table--Create Order Form table T_order (Onumber VARCHAR2 (50) Primary KEY, Trainnum VARCHAR2, STARTTIME VARCHAR2, ENDTIME VARCHAR2 (+), price FLOAT, Seatno VARCHAR2 (+), SEA Ttype VARCHAR2, USERNAME VARCHAR2 (), PhoneNumber VARCHAR2 (+), Idcard VARCHAR2 (e), EMAIL Varch AR2 (+), OBJ VARCHAR2 (+), constraint O_fk_trainnum foreign key (trainnum) references T_train (trainnum)--Constraint foreign key -Associated train table-) CREATE TABLE T_userinfo (USERNAME VARCHAR2, ADDRESS VARCHAR2 (+), EMAIL VARCHAR2 (+), PHONE Number VARCHAR2 (+), Idcard VARCHAR2 (+), OBJ VARCHAR2 (100))--Train offer CREATE TABLE t_favorable (Trainnum varch AR2 (,--) train number STARTTIME VARCHAR2 (50),--Start time ENDTIME VARCHAR2 (50),--end time discount float,--discount price float ,--Discounted price OBJ VARCHAR2 (+),--remarks constraint F_fk_trainnum foreign key (trainnum) references T_train (trainnum)- -Constraint foreign key-associated train table-)

Database creation Common constraints and case references

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.