Solved

How to set che CURRVAL in a sequence without dropping / recreating it.

Posted on 2009-04-15
3
2,364 Views
Last Modified: 2012-05-06
Can you set the currval in a sequence without having to drop and recreate
the sequence?  

Can't we just use alter or update?

Please provide defailed examples.

0
Comment
Question by:hc2342uhxx3vw36x96hq
3 Comments
 
LVL 9

Accepted Solution

by:
MarkusId earned 450 total points
ID: 24146676
Question:  How do we set the LASTVALUE value in an Oracle Sequence?

Answer:  You can change the LASTVALUE for an Oracle sequence, by executing an ALTER SEQUENCE command.

For example, if the last value used by the Oracle sequence was 100 and you would like to reset the sequence to serve 225 as the next value. You would execute the following commands.

alter sequence seq_name
increment by 124;

select seq_name.nextval from dual;

alter sequence seq_name
increment by 1;

Now, the next value to be served by the sequence will be 225.

Source:http://www.techonthenet.com/oracle/sequences.php
0
 
LVL 23

Assisted Solution

by:David
David earned 50 total points
ID: 24147836
Think about it for a moment.  Say that a sequence is defined as a table's primary key.  Having the ability to manually define the current or next values would defeat its purpose to provide unique sequential values.
And of course, Mark meant 224 instead of 124 :D
 
0
 
LVL 1

Author Closing Comment

by:hc2342uhxx3vw36x96hq
ID: 31570351
Many thanks to MarkusId and to dvz for the 124 => 224 bug correction :-D
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question