打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
oracle命令建立主键外键

1、创建一张学生表

SQL> create table t_stu(
  2  stuid number(10) primary key,
  3  stuname varchar2(20) not null,
  4  stusex varchar2(2) default '男' check(stusex in('男','女')));
 
Table created
 
Executed in 0.547 seconds


2、创建一张课程表

SQL> create table t_couse(
  2  couseid number(10) primary key,
  3  cousename varchar2(20) not null,
  4  cousetype varchar2(4));
 
Table created
 
Executed in 0.062 seconds


3、创建一张学生课程成绩表(包括主外键)

SQL> create table t_score(
  2  scoreid number(10) primary key,
  3  stuid number(10) references t_stu(stuid),
  4  couseid number(10),
  5  constraint fk_couseid foreign key(couseid)
  6  references t_couse(couseid)
  7  on delete cascade);
 
Table created
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Primary key 与Unique Key
oracle学习笔记之约束
MySQL: MySQL约束(详细、全)
mysql中key 、primary key 、unique key 与index区别
SQL语句汇总(一)
数据库_mysq单表操作
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服