Updated on 2025-02-27 GMT+08:00

DROP ROLE

Description

Drops a role.

Syntax

DROP ROLE [ IF EXISTS ] role_name [, ...];

Parameters

  • IF EXISTS

    Reports a notice instead of an error if the specified role does not exist.

  • role_name

    Specifies the name of the role to be dropped.

    Value range: an existing role name.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
-- Create a role manager whose password is ********.
openGauss=# CREATE ROLE manager IDENTIFIED BY '********';

-- Create a role with its validity from January 1, 2015 to January 1, 2026.
openGauss=# CREATE ROLE miriam WITH LOGIN PASSWORD '********' VALID BEGIN '2015-01-01' VALID UNTIL '2026-01-01';

-- Change the password of role manager to **********.
openGauss=# ALTER ROLE manager IDENTIFIED BY '**********' REPLACE '********';

-- Change role manager to SYSADMIN.
openGauss=# ALTER ROLE manager SYSADMIN;

-- Drop role manager.
openGauss=# DROP ROLE manager;

-- Drop role miriam.
openGauss=# DROP GROUP miriam;

Helpful Links

CREATE ROLE, ALTER ROLE, and SET ROLE