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 7807617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:54:22+00:00 2026-06-02T02:54:22+00:00

Is there an SQL instruction to retrieve the value of a sequence that does

  • 0

Is there an SQL instruction to retrieve the value of a sequence that does not increment it.

Thanks.

EDIT AND CONCLUSION

As stated by Justin Cave It’s not useful to try to “save” sequence number so

select a_seq.nextval from dual;

is good enough to check a sequence value.

I still keep Ollie answer as the good one because it answered the initial question. but ask yourself about the necessity of not modifying the sequence if you ever want to do it.

  • 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-02T02:54:23+00:00Added an answer on June 2, 2026 at 2:54 am
    SELECT last_number
      FROM all_sequences
     WHERE sequence_owner = '<sequence owner>'
       AND sequence_name = '<sequence_name>';
    

    You can get a variety of sequence metadata from user_sequences, all_sequences and dba_sequences.

    These views work across sessions.

    EDIT:

    If the sequence is in your default schema then:

    SELECT last_number
      FROM user_sequences
     WHERE sequence_name = '<sequence_name>';
    

    If you want all the metadata then:

    SELECT *
      FROM user_sequences
     WHERE sequence_name = '<sequence_name>';
    

    EDIT2:

    A long winded way of doing it more reliably if your cache size is not 1 would be:

    SELECT increment_by I
      FROM user_sequences
     WHERE sequence_name = 'SEQ';
    
          I
    -------
          1
    
    SELECT seq.nextval S
      FROM dual;
    
          S
    -------
       1234
    
    -- Set the sequence to decrement by 
    -- the same as its original increment
    ALTER SEQUENCE seq 
    INCREMENT BY -1;
    
    Sequence altered.
    
    SELECT seq.nextval S
      FROM dual;
    
          S
    -------
       1233
    
    -- Reset the sequence to its original increment
    ALTER SEQUENCE seq 
    INCREMENT BY 1;
    
    Sequence altered.
    

    Just beware that if others are using the sequence during this time – they (or you) may get

    ORA-08004: sequence SEQ.NEXTVAL goes below the sequences MINVALUE and cannot be instantiated
    

    Also, you might want to set the cache to NOCACHE prior to the resetting and then back to its original value afterwards to make sure you’ve not cached a lot of values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a SQL command that will list all the tables in a database
Is there a SQL statement that will list the names of all the tables,
Is there MS SQL Server function that counts the number of times a particular
In sql-server there is function to auto-increment guid fields. CREATEGUID() how can I do
Is there a SQL Server Provider for Joomla? I know that there is a
Is there a SQL Server Provider for Drupal? I know that there is a
Is there a SQL database that allows having a single index on multiple table.column
There is sql statement select distinct create_date from articles Is it possibele to write
Is there a SQL equivalent to #define ? I am using NUMBER(7) for ID's
In SQL Server there is a way to join tables from multiple sql servers

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.