Oracle Build Table Exercises

Source: Internet
Author: User

1, Student table

1 --Create Table2 Create TableT_hq_xs3 (4XuehVARCHAR2(Ten) not NULL,5XingmVARCHAR2( -) not NULL,6XingbCHAR(1)default '1',7Nianl Number,8ZhuanyVARCHAR2( -)9 )Ten  One --Add Comments to the columns AComment on columnT_hq_xs.xueh -    is 'School Number'; -Comment on columnT_HQ_XS.XINGM the    is 'name'; -Comment on columnT_HQ_XS.XINGB -    is 'Sex 1-male, 2-female'; -Comment on columnt_hq_xs.nianl +    is 'Age'; -Comment on columnT_hq_xs.zhuany +    is 'Professional'; A --Create/recreate Primary, unique and foreign KEY constraints at Alter TableT_hq_xs -   Add constraintPk_t_hq_xsPrimary Key(Xueh) -  - --create/recreate CHECK Constraints - Alter TableT_hq_xs -   Add constraintcheck_t_hq_xs_nianl in   Check(nianl> 8  andNianl<  -); - Alter TableT_hq_xs to   Add constraintCHECK_T_HQ_XS_XINGB +   Check(XINGB= '1' ORXingb= '2');

2, score table

1 --Create Table2 Create TableT_HQ_CJ3 (4XuehVARCHAR2(Ten) not NULL,5Java Number(4,1),6Oracle Number(4,1),7Android Number(4,1)8 )9 Ten --Add Comments to the columns OneComment on columnT_hq_cj.xueh A    is 'School Number'; -Comment on columnT_hq_cj.java -    is 'Java Lesson scores'; theComment on columnt_hq_cj.oracle -    is 'Oracle Class Results'; -Comment on columnt_hq_cj.android -    is 'Android class Results'; + --Create/recreate Primary, unique and foreign KEY constraints - Alter TableT_HQ_CJ +   Add constraintPk_t_hq_cjPrimary Key(Xueh) A --create/recreate CHECK Constraints at Alter TableT_HQ_CJ -   Add constraintcheck_t_hq_cj_android -   Check(ANDROID>= 0  andAndroid<= -); - Alter TableT_HQ_CJ -   Add constraintCheck_t_hq_cj_java -   Check(JAVA>= 0  andJava<= -); in Alter TableT_HQ_CJ -   Add constraintcheck_t_hq_cj_oracle to   Check(ORACLE>= 0  andORACLE<= -);

3, Textbook collar use table

--Create TableCreate Tablet_hq_kb (Xuehvarchar2(Ten) not NULL, JavaChar(1)default '0', Javarq date, OracleChar(1)default '0', Oraclerq date);--Add Comments to the columnsComment on columnT_hq_kb.xueh is 'School Number'; Comment on columnT_hq_kb.java is 'whether the Java textbook has been picked up with 0-no, 1-yes'; Comment on columnT_hq_kb.javarq is 'Java Textbook pick -up date'; Comment on columnt_hq_kb.oracle is 'whether Oracle textbooks have been picked up 0-no, 1-yes'; Comment on columnT_hq_kb.oraclerq is 'Oracle Textbook pick -up date';--Create/recreate Primary, unique and foreign KEY constraintsAlter Tablet_hq_kbAdd constraintpk_t_hq_kbPrimary Key(Xueh);--create/recreate CHECK ConstraintsAlter Tablet_hq_kbAdd constraintCheck_t_hq_kb_javaCheck(JAVA= '0' ORJava= '1');Alter Tablet_hq_kbAdd constraintcheck_t_hq_kb_oracleCheck(ORACLE= '0' ORORACLE= '1');

Oracle Build Table Exercises

Related Article

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.