Oracle Dynamic Primary Key sequence Creation

Source: Internet
Author: User
1. Avoid repeated primary keys when you want to retain the original data. Is it difficult to re-create a deleted sequence? This statement is much easier to use. Three parameters: order_sq is the sequence name. Order is the table name, and the internal primary key is id. 2. Use plslq-New-test window to test whether the statement is correct. Thank you. Oracledrop

1. Avoid repeated primary keys when you want to retain the original data. Is it difficult to re-create a deleted sequence? This statement is much easier to use. Three parameters: order_sq is the sequence name. Order is the table name, and the internal primary key is id. 2. Check whether the statement is correct. Use the pl/slq-New-test window for One-Step debugging. Thank you. Oracle drop

1. Avoid repeated primary keys when you want to retain the original data. Is it difficult to re-create a deleted sequence? This statement is much easier to use.
Three parameters: order_sq is the sequence name. Order is the table name, and the internal primary key is id.

2. You can use pl/slq-> New-> test window to perform one-step debugging. Thank you.
Oracle
drop sequence order;declarev_sql varchar2(1000);v_num number(20):=1;beginv_sql:='create sequence order_sq';select max(order_sq.id)+1 into v_num from order;if v_num is null then v_num :=1;end if;v_sql:=v_sql||' minvalue 1 maxvalue 9999999999999999999999999999 start with '||v_num ||' increment by 1 cache 20';execute immediate v_sql;end;

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.