Home » RDBMS Server » Server Administration » Create Sequence script
Create Sequence script [message #180625] Tue, 04 July 2006 08:13 Go to next message
gajini
Messages: 262
Registered: January 2006
Senior Member
Hi,

I've to remove the existing sequences in a schema & then i've to recreate
those sequences with START WITH to old sequences current value.

I've written a script as follows,to recreate current sequences after droppping them,

select 'create sequence ' || sequence_name || ' start with ' ||
' increment by ' || INCREMENT_BY || ' minvalue ' || MIN_VALUE ||
' maxvalue ' || MAX_VALUE || ' CACHE ' || CACHE_SIZE || ' ' || case when cycle_flag='Y' then ' CYCLE ' end
from user_sequences;


Now the problem in this script is,I'm not able to set START WITH current values of the sequence,

I tried with LAST_NUMBER,but it doesn't work for sequence which set with CACHE option.

So,correct my script & guide me to get a script,that gives what i needed.

Thanks,
Gajini


Re: Create Sequence script [message #180642 is a reply to message #180625] Tue, 04 July 2006 09:06 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Quote:

've to remove the existing sequences in a schema & then i've to recreate
those sequences with START WITH to old sequences current value.


So what is the difference?
Why do you want to recreate the sequence?
Waste of everything.
If you still want to recreate the sequence,instead, you can just reset the sequence.
http://www.orafaq.com/forum/m/41107/42800/?srch=reset+sequence#msg_41107
If you still somehow wanted a script, use DBMS_METADATA.
And,Please search the forum before you post.
May be this is the umpteenth time, we requested you to do so.

[Updated on: Tue, 04 July 2006 09:07]

Report message to a moderator

Previous Topic: Create index script
Next Topic: How to move the database
Goto Forum:
  


Current Time: Fri Sep 20 10:40:09 CDT 2024