sql - How to create an Oracle sequence starting with max value from a table? -


Trying to create a sequence in the Oracle that starts with a maximum value from a particular table. Why does not this work?

  Make Transaction Transactions Start from MINVALUE 0 (increase TRANSACTION_LOG to SELECT MAX (trans_seq_no)) increase of 1 cache 20;    

You may want to start with maximum (trans_seq_no) + 1.

clock:

  SQL & gt; Create my_numbers table (my_number number zero primary key); The table was created in SQL & gt; Insert in my_numbers (choose rownum from user_objects); 260 rows were created, SQL & gt; Select Max (my_number) from My_numbers; Max (MY_NUMBER) -------------- 260 SQL & gt; Start my_number_sn sequence with 267; Sequence created sql & gt; Insert my_numbers (my_number) values ​​(my_number_sn.NEXTVAL); Enter the My_numbers (my_number) values ​​(my_number_sn.NEXTVAL) * Error in line 1: ORA-00 001: Exclusive barrier (NEIL.SYS_C00102439) violated  

When you enter a number Make a sequence with, you should remember that for the first time when you choose against the sequence, the oracle will return the initial value assigned by you.

  SQL & gt; Drop sequence my_number_sn; Sequence dropped SQL & gt; Start my_number_sn sequence with 261; Sequence created sql & gt; Insert my_numbers (my_number) values ​​(my_number_sn.NEXTVAL); 1 line has been created  

If you are trying to 'gaparate', then I recommend that

1 do not do this, and # 2 Do not use the sequence for this.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -