CREATE EXTENSION installs and enables a PostgreSQL extension for the current database. Check pg_available_extensions first: default_version shows what the server provides, while installed_version stays empty until the extension is enabled. section 7.2.2 section 8.2
A practical enablement workflow is:
- Query pg_available_extensions to confirm the extension exists and identify its available version. section 7.2.2
- Run CREATE EXTENSION pgcrypto; or CREATE EXTENSION vector; in the target database. section 7.2.2 section 8.2
- Query installed_version or pg_extension to verify that the extension is enabled for the current database. section 7.2.2 section 8.2
Enable pgcrypto for password handling
Run CREATE EXTENSION pgcrypto;, then use crypt('SuperSecret123', gen_salt('bf')) when inserting a password hash. Authentication compares crypt('SuperSecret123', password_hash) with the stored hash; an incorrect password returns no rows. section 7.2.2
Listing 7.1 Checking the pgcrypto extension version
SELECT name, default_version, installed_version FROM pg_available_extensions WHERE name = 'pgcrypto';
Inspect the available and installed pgcrypto versions before and after running CREATE EXTENSION. section 7.2.2
