how to check whether on delete property is set or not in a foreign key constraint in postgresql?

StackOverflow https://stackoverflow.com/questions/22170173

문제

Is there is any query to check whether "on delete" property is being set or not set in a foreign key constraint in postgresql ?

도움이 되었습니까?

해결책

You can query the INFORMATION_SCHEMA:

SELECT  UPDATE_RULE, DELETE_RULE
FROM    INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE   CONSTRAINT_NAME = 'FK_YourForeignKey';

Example on SQL Fiddle

다른 팁

The pg_constraint table in the system catalog contains this information. You can query that:

select confdeltype from pg_constraint where conrelid=xx and contype='f' and conname='xxxx';

The where clauses here are an example - tweak them to suit.

For a portable solution, query information_schema.table_constraints.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top