CREATE USER
Description
Creates a user.
Precautions
- A user created using the CREATE USER statement has the LOGIN permission by default.
- When you run the CREATE USER command to create a user, the system creates a schema with the same name as the user in the database where the command is executed.
- The owner of an object created by a system administrator in a schema with the same name as a common user is the common user, not the system administrator.
Syntax
1
|
CREATE USER user_name [ [ WITH ] option [ ... ] ] [ ENCRYPTED | UNENCRYPTED ] { PASSWORD | IDENTIFIED BY } { 'password' [EXPIRED] | DISABLE }; |
The option clause is used to configure information, including permissions and properties.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
{SYSADMIN | NOSYSADMIN} | {MONADMIN | NOMONADMIN} | {OPRADMIN | NOOPRADMIN} | {POLADMIN | NOPOLADMIN} | {AUDITADMIN | NOAUDITADMIN} | {CREATEDB | NOCREATEDB} | {USEFT | NOUSEFT} | {CREATEROLE | NOCREATEROLE} | {INHERIT | NOINHERIT} | {LOGIN | NOLOGIN} | {REPLICATION | NOREPLICATION} | {VCADMIN | NOVCADMIN} | {PERSISTENCE | NOPERSISTENCE} | CONNECTION LIMIT connlimit | VALID BEGIN 'timestamp' | VALID UNTIL 'timestamp' | USER GROUP 'groupuser' | PERM SPACE 'spacelimit' | TEMP SPACE 'tmpspacelimit' | SPILL SPACE 'spillspacelimit' | NODE GROUP logic_cluster_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
- user_name
Username.
Value range: a string. It must comply with the naming convention. A value can contain a maximum of 63 characters. If a username contains uppercase letters, the database automatically converts the uppercase letters into lowercase letters. To create a username that contains uppercase letters, enclose the username with double quotation marks ("").
- password
Specifies the login password.
The new password must:
- Contain at least eight characters. This is the default length.
- Differ from the username or the username spelled backward.
- Contain at least three of the following character types: uppercase characters, lowercase characters, digits, and special characters (limited to ~!@#$%^&*()-_=+\|[{}];:,<.>/?). If the password contains characters other than the preceding characters, an error will be reported during statement execution.
- The password can also be a ciphertext character string that meets the format requirements. This mode is mainly used to import user data. You are advised not to use it directly. If a ciphertext password is used, the user must know the plaintext corresponding to the ciphertext password and ensure that the plaintext password meets the complexity requirements. The database does not verify the complexity of the ciphertext password. Instead, the security of the ciphertext password is ensured by the user.
- Be enclosed by single quotation marks when a user is created.
Value range: a string
For details about other parameters, see Parameter Description in "CREATE ROLE."
Examples
-- Create user jim whose login password is *******. gaussdb=# CREATE USER jim PASSWORD '********'; -- Alternatively, you can run the following statement: gaussdb=# CREATE USER kim IDENTIFIED BY '********'; -- To create a user with the CREATEDB permission, add the CREATEDB keyword. gaussdb=# CREATE USER dim CREATEDB PASSWORD '********'; -- Change the login password of user jim from ******** to **********. gaussdb=# ALTER USER jim IDENTIFIED BY '**********' REPLACE '********'; -- Add the CREATEROLE permission to jim. gaussdb=# ALTER USER jim CREATEROLE; -- Lock jim. gaussdb=# ALTER USER jim ACCOUNT LOCK; -- Delete users. gaussdb=# DROP USER kim CASCADE; gaussdb=# DROP USER jim CASCADE; gaussdb=# DROP USER dim CASCADE;
Helpful Links
ALTER USER, CREATE ROLE, and DROP USER
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