I did a USER export - user1 has a table which uses a sequence to increment its primary key field. I then imported user1's objects into user2's tablespace. The existing sequence is retained in the import but when I do an insert on the imported table, the next value is not incremented by 1 but by around 20. For example, if the last number in the sequence is 4, I want the next insert to be 5 instead of 21. I've tried including "increment by 1" in the the create sequence statement. What can I do to fix this problem?
03-28-2001, 01:41 PM
This MAY work: analyze the table with compute option.
03-28-2001, 01:50 PM
by default Oracle CACHEs 20 sequence numbers in memory for better performance.
I guess if you look at the last_number in the dba_sequences for a particular sequence you may find if off by a value (20 at the most if it was the default)
Check the CACHE_SIZE of the sequence.
You may want to Alter the sequence to NOCACHE
03-28-2001, 02:07 PM
This is a know issue when you import sequences which were created with cache clause. It's advisable create the sequences with clause nocache due to this problem
If you have to do this often do as rsuri suggested, alter the sequence with nocache clause
03-28-2001, 02:25 PM
I specified NOCACHE in the create sequence statement. It worked.