From bb3b4c6e55e4765c6e99e65bdcbfdcc37d9bd6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Mon, 12 Apr 2021 11:21:56 +0800 Subject: [PATCH] 'commit' --- Document/PG增加列.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Document/PG增加列.txt b/Document/PG增加列.txt index 6bc5f357..ae377a8a 100644 --- a/Document/PG增加列.txt +++ b/Document/PG增加列.txt @@ -14,4 +14,14 @@ where relkind = 'r' and relname like 'j%_r' and relname not like 'pg_%' and rel -- 删除默认值 -ALTER TABLE table_name ALTER COLUMN column_name DROP DEFAULT; \ No newline at end of file +ALTER TABLE table_name ALTER COLUMN column_name DROP DEFAULT; + + +select 'alter table '||pg_class.relname || ' drop constraint '|| pg_constraint.conname ||';' as pk_name from +pg_constraint inner join pg_class +on pg_constraint.conrelid = pg_class.oid +inner join pg_attribute on pg_attribute.attrelid = pg_class.oid +and pg_attribute.attnum = pg_constraint.conkey[1] +inner join pg_type on pg_type.oid = pg_attribute.atttypid where pg_attribute.attname='rowid' +-- where pg_class.relname = 'teacher' +and pg_constraint.contype='p'