主外键约束关系
-
PostgreSQL 数据库基础 如何查看表的主外键等约束关系详解
在PostgreSQL中,可以使用以下命令查看表的主外键等约束关系:,,``sql,SELECT, tc.constraint_name,, tc.table_name AS table_name,, kcu.column_name AS foreign_key_column,, ccu.table_name AS referenced_table_name,, ccu.column_name AS referenced_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',ORDER BY, tc.constraint_name;,``