--建表
--student表+注释
create table student(sno   varchar2(3) not null,sname varchar2(9) not null,ssex  varchar2(3) not null,sbirthday date,sclass varchar2(5),constraint pk_student primary key(sno)
);
comment on column student.sno is '学号(主键)';
comment on column student.sname is '学生姓名';
comment on column student.ssex is '学生性别';
comment on column student.sbirthday is '学生出生年月日';
comment on column student.sclass is '学生所在班级';
--course表+注释
create table course(cno       varchar2(5) not null,cname     varchar2(15) not null,tno       varchar2(3) not null,constraint pk_course primary key(cno)
);
comment on column course.cno is '课程编号(主键)';
comment on column course.cname is '课程名称';
comment on column course.tno is '教工编号(外键)';
--score表+注释
create table score(sno   varchar2(3) not null,cno   varchar2(5) not null,degree   number(4,1),constraint pk_score primary key(sno,cno)
);
comment on column score.sno is '学号(主键)';
comment on column score.cno is '课程编号(主键)';
comment on column score.degree is '成绩';
--teacher表+注释
create table teacher(tno   varchar2(3) not null,tname varchar2(9) not null,tsex  varchar2(3) not null,tbirthday date,prof  varchar2(9),depart varchar2(15) not null,constraint pk_teacher primary key(tno)
);
comment on column teacher.tno is '教工编号(主键)';
comment on column teacher.tname is '教工姓名';
comment on column teacher.tsex is '教工性别';
comment on column teacher.tbirthday is '教工出生年月';
comment on column teacher.prof is '职称';
comment on column teacher.depart is '教工所在单位';
--添加外键
alter table course add constraint fk_tno foreign key(tno) references teacher(tno);
alter table score add constraint fk_sno foreign key(sno) references student(sno);
alter table score add constraint fk_cno foreign key(cno) references course(cno);
--添加数据
--Student表
insert into student(sno,sname,ssex,sbirthday,sclass) values(108,'曾华','男',to_date('1977-09-01','yyyy-mm-dd'),95033);
insert into student(sno,sname,ssex,sbirthday,sclass) values(105,'匡明','男',to_date('1975-10-02','yyyy-mm-dd'),95031);
insert into student(sno,sname,ssex,sbirthday,sclass) values(107,'王丽','女',to_date('1976-01-23','yyyy-mm-dd'),95033);
insert into student(sno,sname,ssex,sbirthday,sclass) values(101,'李军','男',to_date('1976-02-20','yyyy-mm-dd'),95033);
insert into student(sno,sname,ssex,sbirthday,sclass) values(109,'王芳','女',to_date('1975-02-10','yyyy-mm-dd'),95031);
insert into student(sno,sname,ssex,sbirthday,sclass) values(103,'陆君','男',to_date('1974-06-03','yyyy-mm-dd'),95031);
--teacher表
insert into teacher(tno,tname,tsex,tbirthday,prof,depart) values(804,'李诚','男',to_date('1958/12/02','yyyy-mm-dd'),'副教授','计算机系');
insert into teacher(tno,tname,tsex,tbirthday,prof,depart) values(856,'张旭','男',to_date('1969/03/12','yyyy-mm-dd'),'讲师','电子工程系');
insert into teacher(tno,tname,tsex,tbirthday,prof,depart) values(825,'王萍','女',to_date('1972/05/05','yyyy-mm-dd'),'助教','计算机系');
insert into teacher(tno,tname,tsex,tbirthday,prof,depart) values(831,'刘冰','女',to_date('1977/08/14','yyyy-mm-dd'),'助教','电子工程系');
--course表(添加外键后要先填teacher表中数据去满足外键约束)
insert into course(cno,cname,tno) values('3-105','计算机导论',825);
insert into course(cno,cname,tno) values('3-245','操作系统',804);
insert into course(cno,cname,tno) values('6-166','数字电路',856);
insert into course(cno,cname,tno) values('9-888','高等数学',831);
--score表(添加外键后要先填Student,course表中数据去满足外键约束)
insert into score(sno,cno,degree) values(103,'3-245',86);
insert into score(sno,cno,degree) values(105,'3-245',75);
insert into score(sno,cno,degree) values(109,'3-245',68);
insert into score(sno,cno,degree) values(103,'3-105',92);
insert into score(sno,cno,degree) values(105,'3-105',88);
insert into score(sno,cno,degree) values(109,'3-105',76);
insert into score(sno,cno,degree) values(101,'3-105',64);
insert into score(sno,cno,degree) values(107,'3-105',91);
insert into score(sno,cno,degree) values(108,'3-105',78);
insert into score(sno,cno,degree) values(101,'6-166',85);
insert into score(sno,cno,degree) values(107,'6-166',79);
insert into score(sno,cno,degree) values(108,'6-166',81);

Oracle建表及添加数据相关推荐

  1. ORACLE向表中添加数据

    ORACLE向表中添加数据 1.直接插入数据 insert into table_name values('col_text','col_text1'); 顺序一致,给表中的所有列添加一条数据时:(c ...

  2. oracle建表加compress,oracle 建表后添加表注释及字段注释

    oracle添加表注释和表字段注释 创建Oracle数据库表时候加上注释 CREATE TABLE t1( id  varchar2(32) primary key, name VARCHAR2(8) ...

  3. oracle建表后添加数据报错:ORA-01658:无法为表空间中的段创建INITIAL区

    看到这个,是表空间不足咧. 首先呢,我看了下建表时的表空间分配大小,分的挺多了64M,不行,改掉改成64k,ok啦. 别的表也报错.纠结了,决定给表空间大小改了. 1.先看下我的表空的位置 selec ...

  4. oracle添加序列器,Oracle 建表,添加主外键,序列,触发器

    select * from user_objects where object_type='TABLE'; --删除contact表,包括删除与其相关的约束 drop table contact ca ...

  5. oracle建表时添加comment,MYSQL中创建表时可以直接声明comment,ORACLE中似乎不可以,那么oracle该怎样简明地声明comment...

    CREATE TABLE `smbms_user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID', `userCode` varch ...

  6. PyCharm 2018 for mac 数据库实战:链接SQLite、建表、添加、查询数据

    一.前言 最近开始入门python,当然是要使用PyCharm,然后在项目中遇到.db数据库文件,双击打不开?网上找到了windows版本的教程,版本也比较旧,所以有空就来一发,当备忘也好~ 二.链接 ...

  7. oracle建表备份数据,oracle建表备份脚本,如果update的数据不对,可以从WEB_RI_PLYEDR_CED_BAK找回...

    下面是编程之家 jb51.cc 通过网络收集整理的代码片段. 编程之家小编现在分享给大家,也给大家做个参考. --oracle建表备份脚本,如果update的数据不对,可以从WEB_RI_PLYEDR ...

  8. oracle 创建表空间 pcincrease,oracle建表空间 各种语句

    oracle建表空间 各种语句 在创建用户之前,先要创建表空间: 其格式为:格式: create tablespace 表间名 datafile '数据文件名' size 表空间大小; 如: SQL& ...

  9. TABLE 以及 CONSTRAINT(创建TABLE以及CONSTRAINT、修改TABLE结构、建表后添加CONSTRAINT、删除TABLE和CONSTRAINT)

    文章目录 TABLE 以及 CONSTRAINT 创建 TABLE 以及 CONSTRAINT 修改 TABLE 结构 建表后添加 CONSTRAINT 删除 TABLE 和 CONSTRAINT T ...

最新文章

  1. FPGA的设计艺术(6)STA实战之SmartTime时序约束及分析示例(I)
  2. Win2008虚拟化实战之Hyper-V快速设置
  3. how is sales pipeline retrieved from backend
  4. win7桌面图片不显示缩略图问题
  5. win10 SQL SERVER 2017安装详解
  6. (转)思科VPP源码分析(feature机制分析)
  7. 我来做百科(第七天)
  8. mac mysql5.7_Mac 安装配置 MySql(Version 5.7.22) 环境变量
  9. 兄弟j220怎么清零_兄弟j220怎么清零_兄弟Brother全系列打印机清零大全
  10. i2c-tools 使用集锦
  11. AutoCAD自动标注坐标和坐标输出宏
  12. 链表-快慢指针(C++)
  13. jquery+cropper剪切、旋转、缩放图片
  14. 4个让你相见恨晚的电脑操作技巧
  15. 阿里巴巴计算机招聘学历要求,阿里巴巴招程序员,到底看不看学历?
  16. 做 UI 设计用PS还是AI?都不建议!
  17. 工业通讯 | Profinet协议基础知识(三)
  18. 二分法+牛顿迭代法+简化牛顿迭代法+牛顿下山法解方程的近似值
  19. linux设置环境变量设置环境变量
  20. 数据结构-无序(自由)树的简单实现(C++)

热门文章

  1. springboot集成Elasticsearch实现各种搜索功能
  2. 配置QSPI和SFUD
  3. 基本算法——冒泡排序(Python版)
  4. unity-大地图分块加载研究
  5. 凝思系统机器名怎么查看_凝思操作系统常见问题及处理方法
  6. TCP连接断开原理剖析
  7. EXCEL解密打开密码
  8. eclipse实现MySQL分页的类_JavaWeb案例(MVC+MySQL+分页功能)+前后端分离
  9. 利用pip安装python各种库
  10. 2023年除了百度还有哪些搜索引擎推荐?