oracle查询序列取值范围,Oracle(序列 视图)

创建序列

create sequence 名

start with 1

increment by 1

如果就是自增 1 的话就直接写 create sequence 名;

取值的话

序列名.nextval 下一个值

虚列名.currval 当前值

注意:当第一次使用序列的时必须使用 序列名.nextval

例如:

建立序列

create sequence seq_t;

创建表

create table a (id int, name varchar2(20));

插入 insert into a values(seq_t.nextval,'Tom');

就是查看当前select 后的内容

视图 也就是 映射当前 物理地址的表

比如说一个emp表里有14 条记录

PS:我们这里创建一个view as select * from emp where deptno=10

也就是 10部分的 3条记录

如果我们 修改 view 里的内容 则就是对那三条记录进行操作 这样更加安全

1、创建视图

create view 视图名 as 查询语句 ;这里创建的视图就是查询到的内容

如果想限制view 的话 不能让你更改超出自己范围的东西

则需要这样

create view 视图名 as 查询语句 with check option; with read only;

创建索引

create index idx_emp on emp(sal);

建立这样的索引的话 他会自动拿出 当前字段 和 rowid 然后分别进行查找

这样的话 会非常快 而且省资源

create index 名 on 表名(字段名) 可以建立在多个 字段上。

注意:当表中建立主键约束 和唯一性约束 会自动建立索引

下划线

select * from t where name like '/_%'' escape '/';

表T

NAME

--------

_tomcat

tom_cat

tomcat_

查询 以'_'开始 以_'结束 _'中间的三个

1、select * from t where name like '%/_%' escape '/';

2、select * from t where name like '%/_' escape '/';

3、select * from t where ame like '_%/_%_' escape '/';

要求显示结果

FIRST SECOND RESVALUE 及格

-------------------- -------------------- ---------- ------

王无 数学 80 及格

王无 语文 78 及格

王无 英语 90 及格

李远 数学 89 及格

李远 语文 56 不及格

李远 英语 68 及格

赵家 语文 79 及格

赵家 英语 90 及格

张名 数学 88 及格

三张表合并

select s.name first,i.name second,resvalue from studentinfo s,itemcode i,testresult t where s.sid=t.sid and i.kid=t.kid

FIRST SECOND RESVALUE

-------------------- -------------------- ----------

王无 数学 80

王无 语文 78

王无 英语 90

李远 数学 89

李远 语文 56

李远 英语 68

赵家 语文 79

赵家 英语 90

张名 数学 88

然后使用 case when then

结果:

select e.first,e.second,e.resvalue,(case when e.resvalue>60 then '及格' else '不及格' end) 及格 from (select s.name first,i.name second,resvalue from studentinfo s,itemcode i,testresult t where s.sid=t.sid and i.kid=t.kid) e

FIRST SECOND RESVALUE 及格

-------------------- -------------------- ---------- ------

王无 数学 80 及格

王无 语文 78 及格

王无 英语 90 及格

李远 数学 89 及格

李远 语文 56 不及格

李远 英语 68 及格

赵家 语文 79 及格

赵家 英语 90 及格

张名 数学 88 及格

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值