1.check约束
--age只能是1-40岁
alter table info--告诉电脑我要对哪张表进行操作
--添加 约束 约束名 声明这个是什么类型的约束 约束值
add constraint CK_info_age check(age between 1 and 40);
2.子查询
在子查询中,可以实现in and not in
在或不在。
在子查询中可以使用的符号
> < = >= <= != <>
exists 存在
3.排序:
order by
升序排序:asc
降序排序:desc
默认不写的情况下,是升序。
4.分页
select * from (select student.*,rownum rn from student)
where rn >5 and rn <9;
select student.*,rownum rn from student
将student表绑定上rownum
将绑定好之后的表数据作为一张表查询,
要实现分页,就是根据查询的rownum不同。
--start = 2,size = 5
select * from (select s.*,rownum rn from student s)
where rn >(start-1)*size and rn <start*size;
使用sql语句创建以下表
学生信息表:(学号、姓名、年龄、成绩、年级、地址、身份证号、学生证)
年级信息表:(年级编号、年级名称)
地址信息表:(地址编号、地址信息)
学生证信息表:(学生证编号、学生证类型)
创建相应的主外键约束以及check约束
学生信息表至少20条数据。
1.使用排序查询所有学生完整信息
2.使用分页查询所有学生完整信息,要求写出每一页的sql语句。
例如(1-5、6-10、11-15、16-20)至少四条。
--age只能是1-40岁
alter table info--告诉电脑我要对哪张表进行操作
--添加 约束 约束名 声明这个是什么类型的约束 约束值
add constraint CK_info_age check(age between 1 and 40);
2.子查询
在子查询中,可以实现in and not in
在或不在。
在子查询中可以使用的符号
> < = >= <= != <>
exists 存在
3.排序:
order by
升序排序:asc
降序排序:desc
默认不写的情况下,是升序。
4.分页
select * from (select student.*,rownum rn from student)
where rn >5 and rn <9;
select student.*,rownum rn from student
将student表绑定上rownum
将绑定好之后的表数据作为一张表查询,
要实现分页,就是根据查询的rownum不同。
--start = 2,size = 5
select * from (select s.*,rownum rn from student s)
where rn >(start-1)*size and rn <start*size;
使用sql语句创建以下表
学生信息表:(学号、姓名、年龄、成绩、年级、地址、身份证号、学生证)
年级信息表:(年级编号、年级名称)
地址信息表:(地址编号、地址信息)
学生证信息表:(学生证编号、学生证类型)
创建相应的主外键约束以及check约束
学生信息表至少20条数据。
1.使用排序查询所有学生完整信息
2.使用分页查询所有学生完整信息,要求写出每一页的sql语句。
例如(1-5、6-10、11-15、16-20)至少四条。