PostgreSQL Extensions

From Wildsong
Jump to navigationJump to search

I discovered PostgreSQL Extensions while reading about "Large Objects". There is a section in the book PostgreSQL Up and Running.

See what extensions are available

psql -U postgres
SELECT * FROM pg_available_extensions

or if you like

SELECT * FROM pg_available_extensions WHERE name LIKE 'pl%';
    name    | default_version | installed_version |                  comment
------------+-----------------+-------------------+-------------------------------------------
 plpgsql    | 1.0             | 1.0               | PL/pgSQL procedural language
 plpython3u | 1.0             |                   | PL/Python3U untrusted procedural language

See what extensions are installed in the current database

\dx
                                    List of installed extensions
  Name   | Version |   Schema   |                             Description
---------+---------+------------+---------------------------------------------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis | 2.5.1   | public     | PostGIS geometry, geography, and raster spatial types and functions
(2 rows)

Install an extension

CREATE EXTENSION plpython3u;
CREATE EXTENSION plpython3u;
CREATE EXTENSION
gis_data=# \dx
                                      List of installed extensions
    Name    | Version |   Schema   |                             Description
------------+---------+------------+---------------------------------------------------------------------
 plpgsql    | 1.0     | pg_catalog | PL/pgSQL procedural language
 plpython3u | 1.0     | pg_catalog | PL/Python3U untrusted procedural language
 postgis    | 2.5.1   | public     | PostGIS geometry, geography, and raster spatial types and functions
(3 rows)