我是PostgreSQL的新手。我正在努力解决问题。问题是我想从给定表引用的表中删除外键约束。以下查询给出了约束列表。
SELECT
tc.ct_name, tc.table_name AS fg_tb_name, kcu.column_name AS fg_cn_name,
ccu.table_name AS tb_name,
ccu.column_name AS cn_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 ccu.table_name='dimension' AND ccu.table_schema='public';
它给出了由'dimension'表格引用的表格列表和外键名称。
查询结果如下: -
ct_name | fg_tb_name | fg_cn_name | tb_name | cn_name |
--------------------------------------------------------------------------------------
data_ver_fk_cur | data_ver | cur | dimension | dim_id |
--------------------------------------------------------------------------------------
data_ver_fk_reg | data_ver | reg | dimension | dim_id |
--------------------------------------------------------------------------------------
data_ver_fk_ven | data_ver | ven | dimension | dim_id |
---------------------------------------------------------------------------------------
我想删除结果表中存在的所有约束。请建议我。