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

ALTER GROUP

Description

Alters the attributes of a user group.

Precautions

ALTER GROUP is an alias for ALTER ROLE, and it is not a standard SQL command and not recommended. Users can use ALTER ROLE directly.

Syntax

  • Add users to a group.
    ALTER GROUP group_name 
        ADD USER user_name [, ... ];
  • Remove users from a group.
    ALTER GROUP group_name 
        DROP USER user_name [, ... ];
  • Change the name of the group.
    ALTER GROUP group_name 
        RENAME TO new_name;

Parameters

See Parameters in "ALTER ROLE."

Examples

-- Create a user group.
openGauss=# CREATE GROUP super_users WITH PASSWORD "********";

-- Create a user.
openGauss=# CREATE ROLE lche WITH PASSWORD "********";

-- Create a user.
openGauss=# CREATE ROLE jim WITH PASSWORD "********";

-- Add users to a group.
openGauss=# ALTER GROUP super_users ADD USER lche, jim;

-- Remove users from a group.
openGauss=# ALTER GROUP super_users DROP USER jim;

-- Change the name of the group.
openGauss=# ALTER GROUP super_users RENAME TO normal_users;

-- Drop users.
openGauss=# DROP ROLE lche, jim;

-- Drop the user group.
openGauss=# DROP GROUP normal_users;

Helpful Links

CREATE GROUP, DROP GROUP, and ALTER ROLE