oracle 20130913级联

来源:互联网 发布:大数据专业 大学 编辑:程序博客网 时间:2024/06/05 18:43

 

部门表:

createtable DEPARTMENT

(

  ID  NUMBERnotnull,

  NAMEVARCHAR2(20)

)

tablespaceMAINTABLESPACE

  pctfree10

  initrans1

  maxtrans255

  storage

  (

    initial64K

    minextents1

    maxextentsunlimited

  );

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

altertable DEPARTMENT

  addconstraint PK1primarykey (ID)

  usingindex

  tablespace MAINTABLESPACE

  pctfree10

  initrans2

  maxtrans255

  storage

  (

    initial64K

    minextents1

    maxextentsunlimited

  );

 

员工表:

createtable EMPLYEE

(

  ID    NUMBER,

  NAME  VARCHAR2(20),

  DEPTID NUMBER

)

tablespace MAINTABLESPACE

  pctfree10

  initrans1

  maxtrans255

  storage

  (

    initial64K

    minextents1

    maxextentsunlimited

  );

-- Create/Recreate primary, uniqueand foreign key constraints

altertable EMPLYEE

  addconstraint FK1foreignkey (DEPTID)

  references DEPARTMENT (ID)ondeletecascade;