ALTER USER MAPPING

A DDL command for modifying the mapping of a user to a foreign server

ALTER USER MAPPING is a DDL command for modifying the mapping of a PostgreSQL database user to a foreign server

ALTER USER MAPPING was added in PostgreSQL 8.4.

Usage

Change history

The syntax of ALTER USER MAPPING has not been modified since it was added in PostgreSQL 8.4.

Examples

Usage example for ALTER USER MAPPING:

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

postgres=# ALTER USER MAPPING FOR postgres SERVER fdw_test OPTIONS (SET password 'baz');
ALTER USER MAPPING

Note that if an option is provided without specifying one of ADD, SET or DROP, ADD is assumed. This will result in an error if the option was previously set, e.g.:

postgres=# ALTER USER MAPPING FOR postgres SERVER fdw_test OPTIONS (password 'zoo);
ERROR:  option "password" provided more than once

In this case SET must be explicitly provided.

Conversely, if SET is provided for an option which was not previously added, an error will also occur:

postgres=# CREATE USER MAPPING FOR foo SERVER fbw_test options(username 'bar');
CREATE USER MAPPING

postgres=# ALTER USER MAPPING FOR foo SERVER fdw_test OPTIONS (SET password 'baz');
ERROR:  option "password" not found

Categories

DDL, Foreign Data Wrapper (FDW), SQL command, User management

See also

CREATE USER MAPPING, DROP USER MAPPING, pg_user_mapping