-
Hi ,
Can someone suggest the best way to rename a sequence keeping the currval, the same.
-Sravan
-
drop it, then create a new one, start with desired value.
You think I'm going to have an affair with you? --Stanley Kowalski
-
Thanks for the response.
I have lots of sequences and need to script them. Is there any quick way.
-
well, you can do something ilke :
select 'create sequence ' || sequence_name || ' start with ' || sequence_name.nextval || ';'
from user_sequences;
-
You can rename it straight out:
rename old_sequence to new_sequence;
It would say table renamed but you can ignore it. Your sequence will be renamed.
Make sure that you modify your old sequences to set nocache on. Otherwise your new renamed sequence will have the cache sequences incremented.
SQL> select junkseq.nextval from dual;
NEXTVAL
----------
100
SQL> rename junkseq to newseq;
Table renamed.
SQL> select junkseq.nextval from dual;
select junkseq.nextval from dual
*
ERROR at line 1:
ORA-02289: sequence does not exist
SQL> select newseq.nextval from dual;
NEXTVAL
----------
101
[Edited by kris109 on 06-28-2001 at 12:11 PM]
-
Originally posted by kris109
You can rename it straight out:
rename old_sequence to new_sequence;
It would say table renamed but you can ignore it. Your sequence will be renamed.
Gee, this is a nice trick! So simple, yet so elegant.
And as I can see it now from the documentation it is even documented! So besides tables and views (for which most of us was aware of, I gues) you can use RENAME also for sequences and for private synonyms.
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
Sweet. A compliment from jmodic. Now I can die peacefully.
-
LOL!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|