部门表:
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 PK1 primarykey (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 FK1 foreignkey (DEPTID)
references DEPARTMENT (ID) ondeletecascade;