SQL> create sequence ots_seq;


Sequence created.


SQL> select  ots_seq.nextval from dual ;


   NEXTVAL

----------

         1


SQL> /


   NEXTVAL

----------

         2


SQL> /


   NEXTVAL

----------

         3


SQL> /


   NEXTVAL

----------

         4


SQL> /


   NEXTVAL

----------

         5


--PL/SQL 생성

 CREATE or REPLACE PROCEDURE reset_seq (seq_name IN VARCHAR2) as

  curr_val INTEGER;

 BEGIN
     EXECUTE IMMEDIATE 'alter sequence ' ||seq_name||' MINVALUE 0';
     EXECUTE IMMEDIATE 'SELECT ' ||seq_name ||'.nextval FROM dual' INTO curr_val;
     EXECUTE IMMEDIATE 'alter sequence ' ||seq_name||' increment by -'||curr_val;
     EXECUTE IMMEDIATE 'SELECT ' ||seq_name ||'.nextval FROM dual' INTO curr_val;
     EXECUTE IMMEDIATE 'alter sequence ' ||seq_name||' increment by 1';
 END reset_seq;
/


 

Procedure created.


SQL> exec reset_seq('ots_seq');


PL/SQL procedure successfully completed.


SQL>  select  ots_seq.nextval from dual ;


   NEXTVAL

----------

         1


SQL>

사업자 정보 표시
(주)블루원 | 김홍태 | 서울특별시 용산구 원효로 4가 135 금홍 2빌딩 | 사업자 등록번호 : 106-86-76684 | TEL : 02-3272-7200 | Mail : support_ora@blueone.co.kr | 통신판매신고번호 : 호 | 사이버몰의 이용약관 바로가기

+ Recent posts