Oracle dynamically creates auto-increasing Sequences

Source: Internet
Author: User

1.Dynamically create auto-increment Sequences: 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 | 'crement by 1 nocache ';
End if;
Execute immediate v_ SQL;
End;
2 -- create Sequence
Create sequence t-- Use sequence
Select t. nextval from dual -- get the next Sequence Value
Select t. currval from dual -- get the current Sequence Value
Drop sequence g -- delete a sequence
Alter sequence ttt increment by-3 -- modify the sequence

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.