日期:2014-05-16  浏览次数:20445 次

oracle动态创建自动增长的序列
1.动态创建自动增长的序列:
declare
v_sql varchar2(1000);
v_num number(20):=1;
begin
v_sql:='create sequence sqbs ';
select max(sqb.id)+1 into v_num from sqb;
if v_num is null then v_num :=1;
v_sql:=v_sql||' maxvalue 999999 start with '||v_num ||' increment by 1 nocache';
end if;
execute immediate v_sql;
end;
2--创建序列
create sequence t
--使用序列
select t.nextval from dual --获取下一个序列值
select t.currval from dual --获取当前序列值
drop sequence g --删除序列
alter sequence ttt increment by -3--修改序列