Solved

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

Posted on 2009-04-15
3
2,380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

710 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