Solved

Sequences and table volume

Posted on 2014-02-10
5
313 Views
Last Modified: 2014-02-10
Hi,

There was a table with a column based on sequence numbers.
This column is the primary key of the table.
When the table count hits the value 9999, a system error saying all sequences are used will come. Is there any script that can be run by DBA, to monitor this and avoid this overflow ?

Please help..

This is Oracle database.
0
Comment
Question by:neoarwin
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:David
ID: 39847398
A SQL script could be written to query the column value, then mail the DBA when a threshold is passed.  

Unfortunately, primary keys are unique by definition, so any recycling action would be pointless.

Assuming the PK column has a numeric datatype, there is little reason to constrain the counter to four digits -- that sounds to be a poor design.

Subject to your environment and situation, I suspect the solution should be to drop the sequence, and to recreate it using the parameter NOMAXVALUE.  The syntax for the DROP and CREATE statements are found here: click me
0
 

Author Comment

by:neoarwin
ID: 39847460
I don't need a solution as this is 3rd party vendor tool.
Can you give me the script which will be helpful in monitoring ?
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39847710
>>Can you give me the script which will be helpful in monitoring ?

You can query user_sequences with the sequence_names you want to monitor and look at the last_value column to see if you are getting close to the max_value column.
0
 
LVL 23

Expert Comment

by:David
ID: 39847841
I'm puzzled about what action the DBA is expected to take when your threshold is reached.  Yes, one choice is to delete obsolete rows -- but the issue is, the sequence has hit its defined maximum value.  As written, the next insert would be for value 10000 -- that's your error.

The sequence cannot be altered, only dropped and recreated as I explained above.  I'll clarify the obvious, that the new MINVALUE must be higher than the highest existing sequence -- such as 10000.   Hope this helps.
0
 

Author Closing Comment

by:neoarwin
ID: 39847915
Thank you
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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 syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

840 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