`
ghyghoo8
  • 浏览: 190701 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

SQL建表

阅读更多

-- 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;


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics