Search
 
SCRIPT & CODE EXAMPLE
 

SQL

foreign key on table oracle

SELECT c.OWNER, a.TABLE_NAME, a.COLUMN_NAME, a.CONSTRAINT_NAME, 
       c.R_OWNER AS REF_OWNER, cpk.TABLE_NAME AS REF_TABLE, 
       cpk.CONSTRAINT_NAME AS REF_PK
FROM ALL_CONS_COLUMNS a 
JOIN ALL_CONSTRAINTS c ON a.OWNER = c.OWNER
    AND a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
 JOIN ALL_CONSTRAINTS cpk ON c.R_OWNER = cpk.OWNER
    AND c.R_CONSTRAINT_NAME = cpk.CONSTRAINT_NAME
WHERE c.CONSTRAINT_TYPE = 'R' AND c.TABLE_NAME= 'table_name';
Comment

oracle foreign key reference table

SELECT cons.OWNER 			AS CHILD_OWNER,
       cons.TABLE_NAME 		AS CHILD_TABLE,
       cons.CONSTRAINT_NAME AS CONSTAINT_NAME,
       cons.CONSTRAINT_TYPE AS CONSTRAINT_TYPE,
       col.OWNER 			AS PARENT_OWNER,
       col.TABLE_NAME 		AS PARENT_TABLE,
       col.COLUMN_NAME 		AS COLUMN_NAME
FROM DBA_CONS_COLUMNS col, DBA_CONSTRAINTS cons
WHERE cons.R_OWNER = col.OWNER
  AND cons.R_CONSTRAINT_NAME = col.CONSTRAINT_NAME
  AND cons.TABLE_NAME = 'table_name';
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle get trigger ddl 
Sql :: for loop postgresql 
Sql :: bigquery get current date 
Sql :: pentaho + pasar de excel a sql 
Sql :: sql copy table 
Sql :: scaffold npgsql net core 
Sql :: sql query with replace function 
Sql :: mysql full outer join java 
Sql :: get a list of table names and field names from SQL 
Sql :: day of week postgresql 
Sql :: create policy in sql 
Sql :: mysql cli connect with password 
Sql :: distincct sql 
Sql :: sql get guid 
Sql :: how to install mysql server on centos 7 
Sql :: list columns in table postgres 
Sql :: get current date data in mysql 
Sql :: plsql code for deleting a row from nested table in oracle 
Sql :: how to print longest name in sql 
Sql :: mysql update inner 
Sql :: postgres format date in select 
Sql :: alter table sql 
Sql :: copy sql table to new table 
Sql :: how to know password of mysql root in linux terminal 
Sql :: oracle alter tablespace add datafile autoextend max size 
Sql :: sql auto timestamp 
Sql :: mysql insert from local csv 
Sql :: mysql user change password 
Sql :: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint 
Sql :: mysql size of table 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =