Olá, como verifico se minhas constraints estão ligadas no banco inteiro? Preciso de uma query para Oracle e SQL Server.
1 Resposta
Tente isso para ver todas as constraints:
select * from information_schema.referential_constraints
where constraint_schema = 'NOME_DO_SEU_BANCO'
Para SQL Server, tem mais informações aqui: https://msdn.microsoft.com/en-us/library/ms186778.aspx
E para o Oracle tente isso, substituindo os valores:
select R.TABLE_NAME
from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE U
inner join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS FK
on U.CONSTRAINT_CATALOG = FK.UNIQUE_CONSTRAINT_CATALOG
and U.CONSTRAINT_SCHEMA = FK.UNIQUE_CONSTRAINT_SCHEMA
and U.CONSTRAINT_NAME = FK.UNIQUE_CONSTRAINT_NAME
inner join INFORMATION_SCHEMA.KEY_COLUMN_USAGE R
ON R.CONSTRAINT_CATALOG = FK.CONSTRAINT_CATALOG
AND R.CONSTRAINT_SCHEMA = FK.CONSTRAINT_SCHEMA
AND R.CONSTRAINT_NAME = FK.CONSTRAINT_NAME
WHERE U.COLUMN_NAME = 'aaaaaaaaaaaaaaaa'
AND U.TABLE_CATALOG = 'bbbbbbbbbbbbbbbbb'
AND U.TABLE_SCHEMA = 'cccccccccccc'
AND U.TABLE_NAME = 'ddddddddddddd'