oraclesequence语句重置方介绍

秋季,黑彤彤的平棼扒开绿叶往中瞧;小黑灯笼似的枣子挂谦了枝头;像紫玛瑙的葡萄一串串天挂正在葡萄架下,真诱人呀!
在开发过程中,可能会用到oracle sequence语句,本文以oracle sequence语句如何重置进行介绍,需要的朋友可以参考下
Oracle重置sequence语句1
Sql代码
 
DECLARE
n NUMBER(10 );
tsql VARCHAR2(100 );
p_seqName varchar2(20 );
BEGIN
p_seqName := 'SEQ_RUN_ID';
EXECUTE IMMEDIATE 'SELECT ' || p_seqName || '.NEXTVAL FROM dual ' INTO n;
n := - (n - 1);
tsql := 'alter sequence '|| p_seqName ||' increment by ' || n;
EXECUTE IMMEDIATE tsql;
EXECUTE IMMEDIATE 'SELECT ' || p_seqName || '.NEXTVAL FROM dual ' INTO n;
tsql := 'alter sequence '|| p_seqName ||' increment by 1' ;
EXECUTE IMMEDIATE tsql;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( SQLERRM);
END;

Oracle重置sequence语句2
Sql代码
 
CREATE OR REPLACE PROCEDURE RESET_SEQUENCE(p_sSeqName IN VARCHAR2)
IS
n NUMBER(10 );
tsql VARCHAR2(100 );
BEGIN
EXECUTE IMMEDIATE 'SELECT ' || p_sSeqName || '.NEXTVAL FROM dual '
INTO n;
n := - (n - 1);
tsql := 'alter sequence ' || p_sSeqName || ' increment by ' || n;
EXECUTE IMMEDIATE tsql;
EXECUTE IMMEDIATE 'SELECT ' || p_sSeqName || '.NEXTVAL FROM dual '
INTO n;
tsql := 'alter sequence ' || p_sSeqName || ' increment by 1' ;
EXECUTE IMMEDIATE tsql;
EXCEPTION WHEN OTHERS THEN
NULL;
END RESET_SEQUENCE;

以上就是oraclesequence语句重置方介绍。加倍努力,证明你想要的不是空中楼阁。胜利是在多次失败之后才姗姗而来。更多关于oraclesequence语句重置方介绍请关注haodaima.com其它相关文章!

您可能有感兴趣的文章
分享ORACLESEQUENCE跳号总结

详解ORACLESEQUENCE用法

HibernateOraclesequence的如何使用技巧