--创建班级信息表
create table classInfo(
cid int primary key, --班级编号
cname varchar2(50) --班级名称
);
--创建学生信息表
create table student(
sid int primary key, --学号
sname varchar2(50), --姓名
age int --年龄
constraint CK_student_age check(age between 18 and 28),
sex varchar2(2) default '男' --性别
constraint CK_student_sex check(sex='男' or sex='女'),
cid int --所在班级
constraint FK_cid references classInfo(cid),
addr varchar2(100) --住址
);
--创建序列
create sequence seq_cid start with 1001 increment by 1;
create sequence seq_sid start with 1001 increment by 1;
insert into classInfo values(seq_cid.nextval,'YC01班');
insert into classInfo values(seq_cid.nextval,'YC02班');
insert into classInfo values(seq_cid.nextval,'YC03班');
insert into classInfo values(seq_cid.nextval,'YC04班');
insert into student values(seq_sid.nextval,'张三',20,'男',1001,'湖南省长沙市');
insert into student values(seq_sid.nextval,'张三丰',21,'男',1001,null);
insert into student values(seq_sid.nextval,'李四',19,'男',1001,'湖南省益阳市');
insert into student values(seq_sid.nextval,'王五',20,'女',1001,'湖南省邵阳市');
insert into student values(seq_sid.nextval,'赵柳',21,'女',1001,null);
insert into student values(seq_sid.nextval,'钱七',22,'女',1001,'湖南省岳阳市');
insert into student values(seq_sid.nextval,'王八',23,'男',1001,'湖南省衡阳市');
insert into student values(seq_sid.nextval,'田玖',24,'男',1001,null);
insert into student values(seq_sid.nextval,'穷十'
【Oracle】基础查询练习题详解
最新推荐文章于 2021-04-07 16:43:41 发布
本文详细解析了Oracle数据库的基础查询练习题,涵盖SELECT语句的使用、联接操作、子查询以及聚合函数的应用,帮助读者深入理解Oracle数据查询技巧。
摘要由CSDN通过智能技术生成