Last year, I published my Darwin Object Type Accelerator (Dotacc). It allows you to generate objects from a datamodel. What it also does is create collection types for tables that refer to the tabel you want to generate an object for. For some you want that, but for others you don't. Simply because you don't need them to be queried along. Therefor, I added functionality to disable those.
But then comes the question: which are the tables with their foreignkey constraints that refer to this particular table?
The answer is in the ALL_CONSTRAINTS view (with the variants of DBA_% and USER_%).
There are several types of constraints:
- C: Check constraints
- R: Referential -> the particular foreign keys
- P: Primary Key
- U: Unique Key
That get's me:
select fk.* from all_constraints fk join all_constraints rpk on rpk.constraint_name = fk.r_constraint_name where fk.constraint_type='R' and rpk.constraint_type in ('P', 'U') and rpk.table_name = 'DWN_MY_TABLE';
2 comments :
A foreign key can is not required to reference a primary key, a unique key will do too.
You're right. Added 'U' as a constraint type.
Post a Comment