-- Create table
create table STUDENT
(
S# VARCHAR2(20) not null,
SNAME VARCHAR2(20),
SAGE NUMBER,
SSEX VARCHAR2(5)
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table STUDENT
add constraint SYSC000001 primary key (S#)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
----------------------------------------------------------------------
-- Create table
create table COURSE
(
C# VARCHAR2(20) not null,
CNAME VARCHAR2(20),
T# VARCHAR2(20)
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table COURSE
add primary key (C#)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-----------------------------------------------------------------------
create table SC
(
S# VARCHAR2(20) primary key not null ,
C# VARCHAR2(20) ,
score varchar(20) ,
foreign key(S#) references Student(S#),
foreign key(C#) references Course(C#)
)
tablespace USERS;
SQL建表
最新推荐文章于 2022-11-05 14:33:45 发布