我尝试以下操作成功,供参考 (postgresql 14 postgis 3.2.1)
使用idesktop创建数据库连接,public中生成对应对象后。
UPDATE pg_extension SET extrelocatable = true WHERE extname = 'postgis';
ALTER EXTENSION postgis SET SCHEMA target_schema; (此时public.spatial_ref_sys移动到target_schema)
ALTER TABLE IF EXISTS public.smbandregister SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smcodedomains SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smfieldinfo SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smimgregister SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smrangedomains SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smregister SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smsequencemanage SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smtoporelation SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smtoporules SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smdatasourceinfo SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smdomainfield SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smdomains SET SCHEMA target_schema;
ALTER TABLE IF EXISTS public.smuserinfo SET SCHEMA target_schema;
ALTER SEQUENCE IF EXISTS public.sm_seq_datasource OWNED BY NONE;
ALTER SEQUENCE IF EXISTS public.sm_seq_datasource SET SCHEMA target_schema;