CREATE GROUP
Description
Creates a user group.
Precautions
CREATE GROUP is an alias for CREATE ROLE, and it is not a standard SQL syntax and not recommended. Users can use CREATE ROLE directly.
Syntax
CREATE GROUP group_name [ [ WITH ] option [ ... ] ] [ ENCRYPTED | UNENCRYPTED ] { PASSWORD | IDENTIFIED BY } { 'password' [ EXPIRED ] | DISABLE };
The syntax of the option clause (optional) is as follows:
{SYSADMIN | NOSYSADMIN} | {MONADMIN | NOMONADMIN} | {OPRADMIN | NOOPRADMIN} | {POLADMIN | NOPOLADMIN} | {AUDITADMIN | NOAUDITADMIN} | {CREATEDB | NOCREATEDB} | {USEFT | NOUSEFT} | {CREATEROLE | NOCREATEROLE} | {INHERIT | NOINHERIT} | {LOGIN | NOLOGIN} | {REPLICATION | NOREPLICATION} | {PERSISTENCE | NOPERSISTENCE} | CONNECTION LIMIT connlimit | VALID BEGIN 'timestamp' | VALID UNTIL 'timestamp' | RESOURCE POOL 'respool' | USER GROUP 'groupuser' | PERM SPACE 'spacelimit' | TEMP SPACE 'tmpspacelimit' | SPILL SPACE 'spillspacelimit' | NODE GROUP logic_group_name | IN ROLE role_name [, ...] | IN GROUP role_name [, ...] | ROLE role_name [, ...] | ADMIN role_name [, ...] | USER role_name [, ...] | SYSID uid | DEFAULT TABLESPACE tablespace_name | PROFILE DEFAULT | PROFILE profile_name | PGUSER
Parameters
See Parameters in section "CREATE ROLE."
Examples
-- Create a user group. The effect is the same as that of CREATE ROLE. gaussdb=# CREATE GROUP test_group WITH PASSWORD "********"; -- Run CREATE ROLE to create a role. You cannot log in to the database by default. -- Run ALTER ROLE role_name WITH LOGIN to enable users to log in to the database. gaussdb=# CREATE ROLE test_role WITH PASSWORD "********"; -- Run CREATE USER to create a user. A schema with the same name is automatically created and the user has the login permission. gaussdb=# CREATE USER test_user WITH PASSWORD "********"; -- View the user information. gaussdb=# \du test* List of roles Role name | Attributes | Member of ------------+--------------+----------- test_group | Cannot login | {} test_role | Cannot login | {} test_user | | {} -- Query the schema automatically created by running the CREATE USER command. gaussdb=# \dn test* List of schemas Name | Owner -----------+----------- test_user | test_user (1 row) -- Delete. gaussdb=# DROP ROLE test_role; gaussdb=# DROP GROUP test_group; gaussdb=# DROP USER test_user;
Helpful Links
ALTER GROUP, DROP GROUP, and CREATE ROLE
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot