How to move PostGIS extension to a different schema

PostGIS extension will be installed in the public schema by default unless specified anything.

So if its required to use this extension for other schema, we need to relocate it using the following PostgreSQL queries.

Step1: Set the PostGIS extension relocatable.

>UPDATE pg_extension SET extrelocatable = TRUE WHERE extname = 'postgis';

Step2: Change PostGIS extension to required schema.

>ALTER EXTENSION postgis SET SCHEMA NAME;'

Where NAME need to be replaced with the name of the required schema.

That's all…

Leave a Reply