Solved

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

Posted on 2009-04-15
3
2,355 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle Finace 3 66
Error when running a simple alter statement in Aqua studio for Oracle 6 44
return result by latest date - oracle query 21 69
Oracle SQL 6 48
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
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…
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.

910 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

16 Experts available now in Live!

Get 1:1 Help Now