您的位置:首页 > 数据库 > Oracle

oracle数据库表,索引创建实例

2016-05-19 16:24 381 查看
-- Create table

create table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

(

  mmid         NUMBER(14),

  systemid     NUMBER(14),

  objectref    NUMBER(14),

  intid        VARCHAR2(20),

  issno        VARCHAR2(3),

  icn          VARCHAR2(100),

  format       VARCHAR2(50),

  defaulttitle VARCHAR2(500),

  wfstate      VARCHAR2(25),

  height       NUMBER(5),

  width        NUMBER(5),

  uom          VARCHAR2(10),

  imgarea      VARCHAR2(2),

  logo         CHAR(1),

  rfa          VARCHAR2(3999)

)

tablespace TS_LIFE

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 4M

    next 1M

    minextents 1

    maxextents unlimited

  );
-- Create/Recreate indexes 

create index COR_DB_CSDB.CMMO_I1 on COR_DB_CSDB.CDM_MULTIMEDIAOBJ (SYSTEMID, UPPER(ICN))

  tablespace TS_LIFE_IDX

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 3M

    next 1M

    minextents 1

    maxextents unlimited

  );

create index COR_DB_CSDB.CMMO_IFK1 on COR_DB_CSDB.CDM_MULTIMEDIAOBJ (OBJECTREF)

  tablespace TS_LIFE_IDX

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 768K

    next 1M

    minextents 1

    maxextents unlimited

  );

create index COR_DB_CSDB.CMMO_IFK2 on COR_DB_CSDB.CDM_MULTIMEDIAOBJ (SYSTEMID)

  tablespace TS_LIFE_IDX

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 1M

    next 1M

    minextents 1

    maxextents unlimited

  );
-- Create/Recreate primary, unique and foreign key constraints 

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_PK primary key (MMID)

  using index 

  tablespace TS_LIFE_IDX

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 768K

    next 1M

    minextents 1

    maxextents unlimited

  );

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_UK1 unique (INTID, ISSNO)

  using index 

  tablespace TS_LIFE_IDX

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 2M

    next 1M

    minextents 1

    maxextents unlimited

  );

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_IFK1 foreign key (OBJECTREF)

  references COR_DB_CSDB.CDM_OBJECT (OBJECTREF);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_IFK2 foreign key (SYSTEMID)

  references COR_DB_CSDB.CDM_CSDB (SYSTEMID) on delete cascade;

-- Create/Recreate check constraints 

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_CHKIN_FMT

  check (Format IN ('ADI','BMP','CGM','DXF','FAX','FPX','GIF','GKS','JPG','MNG','PBM','PCX','PICT','PNG','RAS','SVG','TGA','TIFF','WMF','AIF','AIFC','AU','CDA','CDDA','KAR','M3U','M3URL','MID','MIDI','MP3','PLS','RMI','SMF','SND','SWA','ULW','WAV','WMA','DS-3DXML','ASM','CATDRAWING','CATPART','CATPRODUCT','CGR','CT','DCR','DRW','DWF','ED','EDZ','FRM','IGES','MODEL','PRT','RH','SLDASM','SLDDRW','SLDPRT','STEP','SWF','U3D','UGS','W3D','WRL','X3D','XV0','XV2','XV3','XVL','ASF','ASR','ASX','AVI','DIF','DV','FLA','FLI','FLV','MHEG','MLV','MOV','MP2','MP2V','MP4','MPE','MPEG-1','MPEG-2','MPG','MPG4','QT','QTR','QTX','RA','RAM','RGB','RM','RMJ','RTS','RTSP','SDP','SMI','SML','VFW','WM','WMP','WMV','WMX','VSD','DOC','MDB','MPP','PDF','PPS','PPT','SDR','SMIL','XLS','DWG','AT_DG','AT_DX','AT_DC','AT','TIF','CG4','EPS','SMG','CDR'));

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_CHKIN_IA

  check (ImgArea IN ('AP','BP','CP','DL','EL','FP','GP','HL','IL'));

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_CHKIN_LOG

  check (Logo IN ('Y','N'));

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_CHKIN_UOM

  check (UOM IN ('mm','cm','in','pix'));

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_FMT

  check ("FORMAT" IS NOT NULL);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_ICN

  check ("ICN" IS NOT NULL);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_IID

  check ("INTID" IS NOT NULL);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_IN

  check ("ISSNO" IS NOT NULL);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_LOG

  check ("LOGO" IS NOT NULL);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_MMI

  check ("MMID" IS NOT NULL);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_SID

  check ("SYSTEMID" IS NOT NULL);

alter table COR_DB_CSDB.CDM_MULTIMEDIAOBJ

  add constraint CMMO_NN_WS

  check ("WFSTATE" IS NOT NULL);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: