当前位置:首页>开发>正文

oracle中,在不用nextval的情况下,如何得到序列当前值 oracle 如何获取刚插入的序列

2023-04-22 09:54:38 互联网 未知 开发

 oracle中,在不用nextval的情况下,如何得到序列当前值 oracle 如何获取刚插入的序列

oracle中,在不用nextval的情况下,如何得到序列当前值?

select your_seq_name.currval from dual
可以得到当前值,且不会增加序列。
不过需要注意的是如果该序列是第一次使用,是不能用currval的,因为还没初始,必须至少用nextval一次后才能用currval。

oracle 如何获取刚插入的序列

你可以先申明一个变量然后将序列值插入到变量当中就可以了 例如
declare p_seq number
begin
select SEQ_MID.NEXTVAL into p_seq from dual
dbms_output.put_line( MSG||p_seq)
end
/

oracle中取序列号是什么意思

Oracle有个东西叫sequence,用于提供连续或者不连续的数字
create sequence seq_a
select seq_a.nextval from dual

insert into t_a(a1,b1)
values(seq_a.nextval,test)

oracle自增序列

declare
i: int
begin
-- 支持insert into values 不支持 insert into select
insert into 表(列1。。列n)
values(值1...值n)
returning id into i
end

最新文章