CREATE USER MAPPING

An SQL command for defining a new mapping of a user to a foreign server

CREATE USER MAPPING is a DDL command for defining a new mapping of a PostgreSQL database user to a foreign server.

CREATE USER MAPPING was added in PostgreSQL 8.4.

psql commands

  • \deu lists available user mappings
  • \deu+ lists available user mappings together with the parameters provided with the OPTIONS clause

Change history

Examples

Usage example for CREATE USER MAPPING:

postgres=# CREATE USER MAPPING
                FOR CURRENT_USER
             SERVER fdw_test
            OPTIONS (user 'foo', password 'bar');
CREATE USER MAPPING

postgres=# \deu
List of user mappings
  Server  | User name 
----------+-----------
 fdw_test | postgres
(1 row)

postgres=# \deu+
                 List of user mappings
  Server  | User name |          FDW options           
----------+-----------+--------------------------------
 fdw_test | postgres  | ("user" 'foo', password 'bar')
(1 row)

Categories

DDL, Foreign Data Wrapper (FDW), SQL command, Users and roles

See also

ALTER USER MAPPING, DROP USER MAPPING, pg_user_mapping, pg_user_mappings