ORACLE建表練習

來源:互聯網
上載者:User

標籤:

1,學生表

 1 -- Create table 2 create table T_HQ_XS 3 ( 4   xueh   VARCHAR2(10) not null, 5   xingm  VARCHAR2(20) not null, 6   xingb  CHAR(1) default ‘1‘, 7   nianl  NUMBER, 8   zhuany VARCHAR2(20) 9 )10 11 -- Add comments to the columns 12 comment on column T_HQ_XS.xueh13   is ‘學號‘;14 comment on column T_HQ_XS.xingm15   is ‘姓名‘;16 comment on column T_HQ_XS.xingb17   is ‘性別 1-男,2-女‘;18 comment on column T_HQ_XS.nianl19   is ‘年齡‘;20 comment on column T_HQ_XS.zhuany21   is ‘專業‘;22 -- Create/Recreate primary, unique and foreign key constraints 23 alter table T_HQ_XS24   add constraint PK_T_HQ_XS primary key (XUEH)25 26 -- Create/Recreate check constraints 27 alter table T_HQ_XS28   add constraint CHECK_T_HQ_XS_NIANL29   check (NIANL > 8 AND NIANL < 50);30 alter table T_HQ_XS31   add constraint CHECK_T_HQ_XS_XINGB32   check (XINGB = ‘1‘ OR XINGB = ‘2‘);

2,成績表

 1 -- Create table 2 create table T_HQ_CJ 3 ( 4   xueh    VARCHAR2(10) not null, 5   java    NUMBER(4,1), 6   oracle  NUMBER(4,1), 7   android NUMBER(4,1) 8 ) 9 10 -- Add comments to the columns 11 comment on column T_HQ_CJ.xueh12   is ‘學號‘;13 comment on column T_HQ_CJ.java14   is ‘java課成績‘;15 comment on column T_HQ_CJ.oracle16   is ‘Oracle課成績‘;17 comment on column T_HQ_CJ.android18   is ‘安卓課成績‘;19 -- Create/Recreate primary, unique and foreign key constraints 20 alter table T_HQ_CJ21   add constraint PK_T_HQ_CJ primary key (XUEH)22 -- Create/Recreate check constraints 23 alter table T_HQ_CJ24   add constraint CHECK_T_HQ_CJ_ANDROID25   check (ANDROID >= 0 AND ANDROID <=100);26 alter table T_HQ_CJ27   add constraint CHECK_T_HQ_CJ_JAVA28   check (JAVA >= 0 AND JAVA <=100);29 alter table T_HQ_CJ30   add constraint CHECK_T_HQ_CJ_ORACLE31   check (ORACLE >= 0 AND ORACLE <=100);

3,課本領用表

-- Create tablecreate table T_HQ_KB(  xueh     varchar2(10) not null,  java     char(1) default ‘0‘,  javarq   date,  oracle   char(1) default ‘0‘,  oraclerq date);-- Add comments to the columns comment on column T_HQ_KB.xueh  is ‘學號‘;comment on column T_HQ_KB.java  is ‘java課本是否已領用0-否,1-是‘;comment on column T_HQ_KB.javarq  is ‘java課本領用日期‘;comment on column T_HQ_KB.oracle  is ‘oracle課本是否已領用0-否,1-是‘;comment on column T_HQ_KB.oraclerq  is ‘oracle課本領用日期‘;-- Create/Recreate primary, unique and foreign key constraints alter table T_HQ_KB  add constraint PK_T_HQ_KB primary key (XUEH);-- Create/Recreate check constraints alter table T_HQ_KB  add constraint CHECK_T_HQ_KB_JAVA  check (JAVA = ‘0‘ OR JAVA = ‘1‘);alter table T_HQ_KB  add constraint CHECK_T_HQ_KB_ORACLE  check (ORACLE = ‘0‘ OR ORACLE = ‘1‘);

 

ORACLE建表練習

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.