oracle数据库序列初始化

CREATE OR REPLACE PROCEDURE "SEQ_SET_ZERO" (resultes out varchar2) is
cursor cur_seq is
select t.sequence_name,t.min_value,t.increment_by,t.last_number
  from user_sequences t;
v_sequence_name varchar2(50);
v_min_value varchar2(50);
v_increment_by varchar2(50);
v_last_number varchar2(50);
/*
  author :football98 
  date : 2015-02-04
  description : 初始化序列。慎用
*/ 
begin
    /*显示声明权限*/
    execute immediate 'grant create  sequence to sbkfw';
    execute immediate 'grant drop any  sequence to sbkfw';
    open  cur_seq;
    fetch cur_seq into v_sequence_name,v_min_value,v_increment_by,v_last_number;
    while cur_seq %found loop
        /*删除序列:*/
        execute immediate 'drop sequence '||v_sequence_name;
        /*创建序列:*/
        execute immediate 'create sequence '||v_sequence_name||' minvalue 1  start with 1 increment by 1';

        fetch cur_seq into v_sequence_name,v_min_value,v_increment_by,v_last_number;
    end loop;
    close cur_seq;
    resultes := '操作成功' ;
    commit;
exception
  when others then
  rollback;
  resultes := '操作失败';
end seq_set_zero;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值