Solved

Sequences and table volume

Posted on 2014-02-10
5
311 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
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.  …
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 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…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now