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