Hola Kernel, ┬┐buscas algo asi?

|SELECT tc.constraint_name,tc.table_name,kcu.column_name,ccu.table_name AS foreign_table_name,ccu.column_name AS foreign_column_name FROM information_schema.table_constraints AS tc JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name =kcu.constraint_name JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name =tc.constraint_name WHERE constraint_type ='FOREIGN KEY'AND tc.table_name='mytable';|


de https://stackoverflow.com/questions/1152260/postgres-sql-to-list-table-foreign-keys

On 2018-04-09 08:46, Kernel wrote:
Hola,

Me pregunto si existe alguna funci├│n que me diga en que tablas esta referenciado un dato.

supongamos que tengo una tabla maestra (A) que tiene un campo id como PRIMARY KEY, a esta se referencian otras tablas (B),(C), etc .., tienen un FOREIGN KEY a la tabla (A)



Antes de borrar un determinado valor de la tabla(A), me gustaria saber en que tablas esta referenciado .

Un Saludo



Reply via email to