Solved

Sequences and table volume

Posted on 2014-02-10
5
316 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
[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
  • 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 77

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
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.
Suggested Courses

622 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