Having a sequence, I need to find out which table.column gets its values. As far as I know, Oracle doesn't keep track of this relationship. So, looking up for the sequence in source code would be the only way. Is that right?
Anyone knows of some way to find out this sequence-table relationship?
You should use the query "select sequence_name from all_sequences;" to find out all sequences accessible to the schema user.
An Oracle Sequence is a database object, just like a table or view, that represents a sequence of integers that can be used by any table or view in the global database namespace. A Sequence's values can be accessed using the NEXTVAL, and CURRVAL pseudo-columns. A Sequence can be ascending or descending.
A sort sequence table is an object that contains the weight of each single-byte graphic character within a specified coded character set identifier (CCSID). The system-recognized identifier for the sort sequence table object type is *TBL.
A sequence is an object in Oracle that is used to generate a number sequence. This can be useful when you need to create a unique number to act as a primary key.
The problem is that Oracle allows us to use one sequence to populate columns in several tables. Scenarios where this might be desirable include super-type/sub-type implementations.
You can use the dependencies in the data dictionary to identify relationships. For instance, if you use triggers to assign the values then this query will help you:
select ut.table_name
, ud.referenced_name as sequence_name
from user_dependencies ud
join user_triggers ut on (ut.trigger_name = ud.name)
where ud.type='TRIGGER'
and ud.referenced_type='SEQUENCE'
/
If you use PL/SQL then you can write something similar for TYPE in ('PACKAGE BODY', 'PROCEDURE', 'FUNCTION')
, although you will still require some trawling through the source code to assign tables and sequences when you have multiple hits.
In the database you can search all stored code in your schema like this:
select type, name, line, text
from all_source
where owner = 'MYSCHEMA'
and upper(text) like '%MYSEQ.NEXTVAL%';
In SQL Developer, there is a report to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With