How to find Sequences associated to a table [message #614832] |
Tue, 27 May 2014 12:48 |
|
gorants
Messages: 85 Registered: May 2014 Location: ATL
|
Member |
|
|
Hello All,
How do we find sequences associated to a table.
Ex : In EMP table emp_id is primary key it will get incremented from sequnece , how do i know which sequence was get used by EMP table.
thanks
|
|
|
Re: How to find Sequences associated to a table [message #614833 is a reply to message #614832] |
Tue, 27 May 2014 12:50 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
There is no such thing.
A sequence is a stand alone object. You can use it in a table, you can use it in many tables, you can use it in tables in other schemas, or you can choose not to use it.
[addendum]
What I am saying is that you need to look at your application code. there is nothing in any oracle table that has this information.
[Updated on: Tue, 27 May 2014 12:51] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: How to find Sequences associated to a table [message #614854 is a reply to message #614832] |
Tue, 27 May 2014 14:55 |
|
EdStevens
Messages: 1376 Registered: September 2013
|
Senior Member |
|
|
As others have said, there is no inherent relationship. Since use of a sequence to populate a PK column (or any other possible use, for that matter) is an application issue you need to consider everywhere such code could reside.
Ideally it would be in an ON INSERT trigger
but it could also be in an INSERT statement in any pl/sql or java code in the database
or it could be in an INSERT statement embedded in application code that resides OUTSIDE the database.
My point is that while there are some 'best practices' to help locate it, there are no guarantees. Worst case is the reference to the sequence could even be in a little sql script sitting on someones local desktop machine up in the accounting department. Also there could be some INSERT statements that use the sequence, and some other code somewhere else (like the guy in Accounting) that also does an insert on the table and does NOT use the sequence.
[Updated on: Tue, 27 May 2014 14:55] Report message to a moderator
|
|
|