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'