How do I import modules or install extensions in PostgreSQL 9.1+? How do I import modules or install extensions in PostgreSQL 9.1+? postgresql postgresql

How do I import modules or install extensions in PostgreSQL 9.1+?


Postgrseql 9.1 provides for a new command CREATE EXTENSION. You should use it to install modules.

Modules provided in 9.1 can be found here.. The include,

adminpack , auth_delay , auto_explain , btree_gin , btree_gist, chkpass , citext , cube , dblink , dict_int, dict_xsyn , dummy_seclabel , earthdistance , file_fdw , fuzzystrmatch, hstore , intagg , intarray , isn , lo, ltree , oid2name , pageinspect , passwordcheck , pg_archivecleanup, pgbench , pg_buffercache , pgcrypto , pg_freespacemap , pgrowlocks, pg_standby , pg_stat_statements , pgstattuple , pg_test_fsync , pg_trgm, pg_upgrade , seg , sepgsql , spi , sslinfo , tablefunc, test_parser , tsearch2 , unaccent , uuid-ossp , vacuumlo, xml2

If for instance you wanted to install earthdistance, simply use this command:

CREATE EXTENSION earthdistance;

If you wanted to install an extension with a hyphen in its name, like uuid-ossp, you need to enclose the extension name in double quotes:

CREATE EXTENSION "uuid-ossp";


While Evan Carrol's answer is correct, please note that you need to install the postgresql contrib package in order for the CREATE EXTENSION command to work.

In Ubuntu 12.04 it would go like this:

sudo apt-get install postgresql-contrib

Restart the postgresql server:

sudo /etc/init.d/postgresql restart

All available extension are in:

/usr/share/postgresql/9.1/extension/

Now you can run the CREATE EXTENSION command.


In addition to the extensions which are maintained and provided by the core PostgreSQL development team, there are extensions available from third parties. Notably, there is a site dedicated to that purpose: http://www.pgxn.org/