(一)分页查询
分页查询根据rownum(行号)来进行分页限制,其中要用嵌套的select语句来进行查询。
!--第一层的rownum需要在order by rownum 排序之后查询出来
select * from(select t2.* from (select rownum r,t.* from emp t order by rownum) t2 where t2.r>=1) t3 where t3.r<=5
(二)check语句
check的语句就是检查,在存储数据的时候,是否有不符合表的数据插入。不符合则不能插入。
create table test_table(
t_id number(10),
t_name varchar2(10),
t_age number(2),
constraint check_age check (t_age>18 and t_age<36)
)
!--当向表中插入的t_age不在限制范围内,就会报错。
!--当表创建成功之后添加check,前提是表中的t_age都符合现在添加的限制条件,否则会出现违反检查约束条件错误
alter table test_table add constraint check_age check (t_age>18 and t_age<60)
!--删除check检查约束
alter table test_table drop constraint check_age
(三)NOT NULL约束
!--根据上面的表设置非空约束
alter table test_table modify t_name not null
!--设置为可以为null
alter table test_table modify t_name null