Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:56:05+00:00 2026-06-05T17:56:05+00:00

I have some inserts in a development environment to release, the developer has not

  • 0

I have some inserts in a development environment to release, the developer has not used sequences to obtain the correct identifiers when doing inserts. What he has done is gone into the production database and found out what the largest identifier is and added a few hundred numbers to it. To boot he has now left the company.

So the script to prod is filled with hundreds of these:

INSERT INTO table (sequencecol, cola, colb) VALUES (90001,'test','test');

INSERT INTO childtableB (foreignkeyTableA, cola) VALUES (90001,'test')

When it should have been

INSERT INTO tableA (sequencecol, cola, colb) VALUES (tablesequence.NEXTVAL,'test','test');
INSERT INTO childtableB (foreignkeyTableA, cola) VALUES (tablesequence.CURRVAL,'test')

The scneario i am dealing with is more complicated than this, and i dont have the time to rewrite, instead i just want to set the sequence to the max value of the records inserted as part of this script.

Is it possible to alter the value of a sequence to set it to the value of the highest value +1 of the records i am to insert?

I’m open to better suggestions

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:56:07+00:00Added an answer on June 5, 2026 at 5:56 pm

    The approach is good.

    But looking at the answers to this related questions, it is not easy to just reset a sequence to a particular value.

    Since you don’t need to go back here, maybe just write a small script that in a loop consumes numbers from the sequence until it’s where you need it to be.

    Or, if it is a lot of numbers this:

    -- First, alter the object so the next increment will jump 1000 instead of just 1.
    alter sequence myschema.seq_mysequence increment by 1000;
    
    -- Run a select to actually increment it by 1000
    select myschema.seq_mysequence.nextval from dual;
    
    -- Alter the object back to incrementing only 1 at a time
    alter sequence myschema.seq_mysequence increment by 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started in web development not long time ago. I know some stuff
I have some code that inserts a record into a SQLite table: $statement =
I have some code that inserts a list item into a list... I then
I have a stored procedure that does, among other stuff, some inserts in different
I have a classic ASP application which inserts some values into a word file
I have a Greasemonkey script that dynamically inserts an HTML form into some web
I have a bit of JavaScript that builds some HTML for me and inserts
I have a VBA script that inserts long strings into Excel cells. In some
I have seen prefix N in some insert T-SQL queries. Many people have used
I've been a web developer for some time now, and have recently started learning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.