“Tabla de referencia de Key Oracle Foreign Key” Código de respuesta

Clave extranjera en la tabla 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';
VasteMonde

Tabla de referencia de Key Oracle Foreign Key

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';
VasteMonde

Respuestas similares a “Tabla de referencia de Key Oracle Foreign Key”

Preguntas similares a “Tabla de referencia de Key Oracle Foreign Key”

Más respuestas relacionadas con “Tabla de referencia de Key Oracle Foreign Key” en Sql

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código