• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
静风铃
博客园    首页    新随笔    联系   管理    订阅  订阅

数据库-代码建表

-- Create table
create table COURSE
(
cno VARCHAR2(10) not null,          列名  数据类型  是否可为空
cname VARCHAR2(20) not null,          列名  数据类型  是否可为空
tno VARCHAR2(6) not null          列名  数据类型  是否可为空
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Add comments to the columns           添加注释
comment on column COURSE.cno          在cno列中添加注释
is '课程号(主键)';                   注释为  ‘XXX’
comment on column COURSE.cname
is '课程名称';
comment on column COURSE.tno
is '教工编号(外键)';


-- Create/Recreate primary, unique and foreign key constraints
alter table COURSE
add constraint C_COUNRSE primary key (CNO)          添加cno为主键
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table COURSE
add constraint C_TNO foreign key (TNO)          添加 tno 为外键
references TEACHER (TNO);                外键关联 teacher  表中的 tno

posted @ 2016-10-11 08:36  静风铃  阅读(525)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3