1

Temat: wyswietlanie zaleznosci

Czy istnieje mozliwosc wyswietlenia powiazan z dana tabela za pomoca polecenie sql? Jesli mamy np. tabele A, B i C z czego tabele A i B posiadaja klucze obce wskazujace na tabele C, to jak wyswietlic powiazania do tabeli C?

2

Odp: wyswietlanie zaleznosci

select * from information_schema.key_column_usage t1, (select * from information_schema.referential_constraints where unique_constraint_name in (select constraint_name from information_schema.table_constraints where constraint_type in 
('PRIMARY KEY','UNIQUE') and table_name in ('c'))) t2 where t1.constraint_name=t2.constraint_name;

3

Odp: wyswietlanie zaleznosci

select * from information_schema.key_column_usage t1, (select * from information_schema.referential_constraints where unique_constraint_name in (select constraint_name from information_schema.table_constraints where constraint_type in 
('PRIMARY KEY','UNIQUE') and table_name in ('c'))) t2 where t1.constraint_name=t2.constraint_name;