Sequence goes backward

Source: Internet
Author: User
Tags sql using
When a database was imported yesterday, the user reflected that the sequence imported was smaller than the sequence value already imported into the table. The cause is that seq import may be performed in the production data, leading to repeated operations. To solve this problem, I extend all sequence of the current user to 200. The specific operation is as follows: Create Table mahanso_test (ID number, sequence varchar2 (100 )) declare cursor c_cursor is select sequence_name from user_sequences; v_sequences_name user_sequences.sequence_name % type; v_ SQL varchar2 (2000); v_insert_ SQL varchar2 (2000); v_sequences_value number; begin -- implicitly open the cursor for v_sequences_name in c_cursor loop -- implicitly execute a fetch statement for int in 1 .. 1000 loop v_ SQL: = 'select' | v_sequences_name.sequence_name | '. nextval from dual '; -- v_ SQL: = v_sequences_name; -- merge (v_ SQL); execute immediate v_ SQL into v_sequences_value; v_insert_ SQL: = 'insert into mahanso_test values (: 1,: 2 )'; execute immediate v_insert_ SQL using v_sequences_value, v_sequences_name.sequence_name; commit; end loop; -- implicitly monitor c_sal % notfound end loop; -- implicitly close the cursor end;
 
Note: This script was modified online.

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.