如何建立表外键

谁是我的谁的谁 2004-07-07 09:17:26
差了许多书也不会
学生表student (id, name , sex )
成绩表score (id ,math )
如何创建表,要求 有主键,有约束
...全文
179 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
postform999 2005-07-12
  • 打赏
  • 举报
回复
哦可!
learningoracle 2004-07-07
  • 打赏
  • 举报
回复
constraint FK_STUDENT foreign key ( id ) references student( id ) ) ;
就是把score的id 做為外鍵與student的id建立關聯。FK_STUDETN是外鍵的名子。
learningoracle 2004-07-07
  • 打赏
  • 举报
回复
create table student(id char(10),name varchar(8),sex char(1));
alter table student add constraint pk_student primary key(id);
create table score( id char(10),math number(5,2));
alter table score add constraint fk_scroe foreign key(id) references student;
  • 打赏
  • 举报
回复
能对constraint FK_STUDENT foreign key ( id ) references student( id ) ) ;
解释一下忙?
绝对给分
tyrone98 2004-07-07
  • 打赏
  • 举报
回复
create table student( id char(10) primary key , name varchar2(20) , sex number(1) ) ;
create table score( id char(10) , math number(5,2) ,constraint FK_STUDENT foreign key ( id ) references student( id ) ) ;
你可以用一些数据库建模工具来建表
jiezhi 2004-07-07
  • 打赏
  • 举报
回复
简单的做法是使用数据库建模工具:visio、erwin4、PowerDesign
如果你使用sql的话,麻烦一些,可以参考sql reference的语法介绍

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧