PG 修改表结构提示有试图依赖的处理方法
ALTER TABLE victim ALTER COLUMN victim_belong_url TYPE varchar(1000) USING victim_belong_url::varchar(1000);
修改字段长度
通过修改 pg_attribute 基表的方式来绕开这个限制
#通过表名查出attrelid SELECT relname, attname,attnum,attrelid,attname FROM pg_class c,pg_attribute attr WHERE relname = '表名' AND c.oid = attr.attrelid; #修改字段长度 注意 varchar类型额外加4 update pg_attribute set atttypmod =34 WHERE attrelid ='a'::regclass AND attname = '字段名'; #查询修改后长度 SELECT atttypmod FROM pg_attribute WHERE attrelid = '3648177'::regclass AND attname = '字段名';
OR
update pg_attribute set atttypmod =1004 WHERE attrelid =(SELECT attrelid FROM pg_class c,pg_attribute attr WHERE relname = 'victim' AND c.oid = attr.attrelid and attname = 'victim_belong_url') AND attname = 'victim_belong_url';
查看表结构确认
\d+ victim