Using psql how do I list extensions installed in a database?

PostgresqlPsqlPostgresql Extensions

Postgresql Problem Overview


How do I list all extensions that are already installed in a database or schema from psql?

See also

Postgresql Solutions


Solution 1 - Postgresql

In psql that would be

\dx

See the manual of psql for details.

Doing it in plain SQL it would be a select on pg_extension:

SELECT * 
FROM pg_extension;

Solution 2 - Postgresql

Additionally if you want to know which extensions are available on your server: SELECT * FROM pg_available_extensions.

See pg_available_extensions and pg_available_extension_versions.

Solution 3 - Postgresql

This SQL query gives output similar to \dx:

SELECT e.extname AS "Name", e.extversion AS "Version", n.nspname AS "Schema", c.description AS "Description" 
FROM pg_catalog.pg_extension e 
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace 
LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass 
ORDER BY 1;

Thanks to https://blog.dbi-services.com/listing-the-extensions-available-in-postgresql/

Solution 4 - Postgresql

Just a comment that whether you run as suggested above, in psql either

\dx

or

select extname from pg_extension ;

Keep in mind that

  1. Make sure you are connected to the right database. As your extensions are loaded database specific.
  2. Any extensions added to template1 database will by definition, appear on all databases.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionARVView Question on Stackoverflow
Solution 1 - Postgresqla_horse_with_no_nameView Answer on Stackoverflow
Solution 2 - PostgresqlDave GlassborowView Answer on Stackoverflow
Solution 3 - Postgresqlhit3kView Answer on Stackoverflow
Solution 4 - PostgresqlSumit SView Answer on Stackoverflow