Oracle建表

  -- Create table
  create table T_HQ_XS
  (
    xueh   VARCHAR2(10) not null,
    xingm  VARCHAR2(20) not null,
    xingb  CHAR(1) default '1',
    nianl  NUMBER,
    zhuany VARCHAR2(20)
  )
 
 -- Add comments to the columns 
 comment on column T_HQ_XS.xueh
   is '学号';
 comment on column T_HQ_XS.xingm
   is '姓名';
 comment on column T_HQ_XS.xingb
   is '性别 1-男,2-女';
 comment on column T_HQ_XS.nianl
   is '年龄';
 comment on column T_HQ_XS.zhuany
   is '专业';
 -- Create/Recreate primary, unique and foreign key constraints 
 alter table T_HQ_XS
   add constraint PK_T_HQ_XS primary key (XUEH)
 
 -- Create/Recreate check constraints 
 alter table T_HQ_XS
   add constraint CHECK_T_HQ_XS_NIANL
   check (NIANL > 8 AND NIANL < 50);
 alter table T_HQ_XS
   add constraint CHECK_T_HQ_XS_XINGB
   check (XINGB = '1' OR XINGB = '2');

 

posted @ 2015-10-25 21:28  呼哧呼哧  阅读(98)  评论(0编辑  收藏  举报