Updated on 2024-05-07 GMT+08:00

ALTER GROUP

Function

ALTER GROUP modifies the attributes of a user group.

Precautions

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

Syntax

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

Parameter Description

See Parameters in section "ALTER ROLE."

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- Create a user group.
gaussdb=# CREATE GROUP super_users WITH PASSWORD "*********";

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

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

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

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

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

-- Delete the user.
gaussdb=# DROP ROLE lche, jim;

-- Delete the user group.
gaussdb=# DROP GROUP normal_users;

Helpful Links

CREATE GROUP, DROP GROUP, and ALTER ROLE