Wednesday, September 10, 2008

DBA_CONS_COLUMNS

DBA_CONS_COLUMNS describes all columns in the database that are specified in constraint definitions. Its columns are the same as those in "ALL_CONS_COLUMNS".

Related Views

  • ALL_CONS_COLUMNS describes columns that are accessible to the current user and that are specified in constraints.
  • USER_CONS_COLUMNS describes columns that are owned by the current user and that are specified in constraints.

Column

Datatype

NULL

Description

OWNER

VARCHAR2(30)

NOT NULL

Owner of the constraint definition

CONSTRAINT_NAME

VARCHAR2(30)

NOT NULL

Name of the constraint definition

TABLE_NAME

VARCHAR2(30)

NOT NULL

Name of the table with constraint definition

COLUMN_NAME

VARCHAR2(4000)

Name of the column or attribute of the object type column specified in the constraint definition

Note: If you create a constraint on a user-defined REF column, the system creates the constraint on the attributes that make up the REF column. Therefore, the column names displayed in this view are the attribute names, with the REF column name as a prefix, in the following form:

"REF_name"."attribute"

POSITION

NUMBER

Original position of column or attribute in the definition of the object

Note:

1. List missing foriegn key values. Useful for resolving ORA-02298.

select 'select '||cc.column_name-

||' from '||c.owner||'.'||c.table_name-

||' a where not exists (select ''x'' from '-

||r.owner||'.'||r.table_name-

||' where '||rc.column_name||' = a.'||cc.column_name||')'

from dba_constraints c,

dba_constraints r,

dba_cons_columns cc,

dba_cons_columns rc

where c.constraint_type = 'R'

and c.owner not in ('SYS','SYSTEM')

and c.r_owner = r.owner

and c.owner = cc.owner

and r.owner = rc.owner

and c.constraint_name = cc.constraint_name

and r.constraint_name = rc.constraint_name

and c.r_constraint_name = r.constraint_name

and cc.position = rc.position

and c.owner = '&table_owner'

and c.table_name = '&table_name'

and c.constraint_name = '&constraint_name'

order by c.owner, c.table_name, c.constraint_name, cc.position

/

Oracle data dictionary views

Oracle dynamic performance views

No comments:

Post a Comment