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 :: MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: sql wildcards 
Sql :: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed 
Sql :: selecting names ending with vowels in sql 
Sql :: java.sql.sqlexception: access denied for user 
Sql :: max in postgresql 
Sql :: postgres select from values 
Sql :: docker mysql connection refused 
Sql :: ssms connect with connection string 
Sql :: mysql storage engines 
Sql :: ssms keyboard shortcuts 
Sql :: Resolved [java.sql.SQLException: ORA-29977: Unsupported column type for query registration in guaranteed mode ] 
Sql :: sql server isnull function nor working count 
Csharp :: c# mark as deprecated 
Csharp :: hello world program in c# 
Csharp :: asp.net validate web.config 
Csharp :: how to check the tag of a collider in unity 
Csharp :: check if string is email c# 
Csharp :: change sprite of gameobject unity 
Csharp :: save file with unique name c# 
Csharp :: json ignore property c# 
Csharp :: c# windows grab screenshot 
Csharp :: loop through enum c# 
Csharp :: writeline c# 
Csharp :: find closest gameobject unity 
Csharp :: c# remove all null from list 
Csharp :: unity look at 2d 
Csharp :: unity print 
Csharp :: swagger authentication bearer .net core 
Csharp :: unity object follow mouse 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =