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 :: could not assemble any primary key columns for mapped table sqlalchemy 
Sql :: how to convert external table to managed table in hive 
Sql :: how to filter repeated same result using sql query 
Sql :: graphql 
Sql :: postgresql port 5432 not open 
Sql :: mariadb create index if not exists 
Sql :: how to relationship query two different tables in MySQL 
Sql :: add column postgresql 
Sql :: get current date sql 
Sql :: mysql max() 
Sql :: mysql delete older duplicates 
Sql :: how to update sql server version 
Sql :: xampp mysql command to import a large database 
Sql :: how to get table id sequence postgres 
Sql :: sql add calculated column 
Sql :: sql select on string 
Sql :: SQL INNER JOIN With Three Tables 
Sql :: operator in sql 
Sql :: sql select like 
Sql :: check if table is Temporal 
Sql :: switch users mysql 
Sql :: oracle sql all days except weekends 
Sql :: show sql property syntax for jpa. 
Sql :: mysql update multiple columns 
Sql :: create user with encrypted password postgresql 
Sql :: mysql even numbers 
Sql :: java.sql.sqlexception: the url cannot be null 
Sql :: mysql max connections exceeded max_connections_per_hour 
Sql :: install pymysql in python 3 in windows 7 v2.7.10 codes with pip 
Sql :: convert minutes to hours in sql 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =