Updated on 2024-06-03 GMT+08:00

DROP USER MAPPING

Description

DROP USER MAPPING is used to delete the user mapping from a user to a foreign server.

Syntax

DROP USER MAPPING [ IF EXISTS ] FOR { user_name | USER | CURRENT_USER | PUBLIC } SERVER server_name;

Parameters

  • IF EXISTS

    Reports a notice instead of an error if the user mapping does not exist.

    Different from many statements, the IF EXISTS parameter is used only for the DROP USER MAPPING statement. When the CREATE USER MAPPING statement uses this parameter, a syntax error is reported.

  • user_name

    Specifies username of the mapping.

    CURRENT_USER and USER match the name of the current user. PUBLIC is used to match all current and future usernames in the system.

  • server_name

    Specifies name of the server to which the user is mapped.

Examples

-- Create a role.
gaussdb=# CREATE ROLE bob PASSWORD '********';

-- Create a foreign server.
gaussdb=# CREATE SERVER my_server FOREIGN DATA WRAPPER log_fdw;

-- Create a user mapping.
gaussdb=# CREATE USER MAPPING FOR bob SERVER my_server OPTIONS (USER 'bob', PASSWORD '********');

-- Modify the user mapping.
gaussdb=# ALTER USER MAPPING FOR bob SERVER my_server OPTIONS (SET PASSWORD '********');

-- Delete the user mapping.
gaussdb=# DROP USER MAPPING FOR bob SERVER my_server;

-- Delete the foreign server.
gaussdb=# DROP SERVER my_server;

-- Delete the role.
gaussdb=# DROP ROLE bob;