Solved

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

Posted on 2009-04-15
3
2,339 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
Comment Utility
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
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  â€¦
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 explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now