Purpose
The CREATE USER statement is used to create a new OceanBase Database user. After a new user is created, you can use the new user to connect to OceanBase Database.
Privilege requirements
To execute the CREATE USER statement, the current user must have the CREATE USER system privilege. For more information about OceanBase Database privileges, see Privilege classification in Oracle mode.
Syntax
CREATE USER user_name
IDENTIFIED BY [VALUES] password
[REQUIRE {NONE | SSL | X509 | tls_option}]
[PROFILE profile_name]
[DEFAULT TABLESPACE tablespace_name];
tls_option:
CIPHER cipher_name
| ISSUER issuer_name
| SUBJECT subject_name
Parameters
| Parameter | Description |
|---|---|
| user_name | The username. After a new user is created, a new row is added to the dba_users table. If a user with the same name already exists, an error is returned. |
| IDENTIFIED BY | Specifies the password for the new user. The password is stored in plain text in the dba_users table. The server will store it as ciphertext. If the password contains special characters ~!@#%^&*_-+=`|(){}[]:;',.?/, you must enclose it in double quotation marks ("). |
| IDENTIFIED BY VALUES | Specifies the password for the new user. The password is stored in ciphertext in the dba_users table. |
| REQUIRE | Specifies the password verification requirements for the user. Valid values:
|
| tls_option | Specifies the specific option for TLS requirements. Valid values:
|
| PROFILE | Specifies the user profile. A user profile is a predefined set of privileges and limitations that can be applied to the created user. |
| DEFAULT TABLESPACE | Specifies the default tablespace for the user. A tablespace is a logical structure used to store user data. |
Examples
Create a user named
test1with a plaintext password.obclient [SYS]> CREATE USER test1 IDENTIFIED BY "********";Create a user named
test2with an encrypted password and specify that SSL connections must be used for authentication.obclient [SYS]> CREATE USER test2 IDENTIFIED BY VALUES "********" REQUIRE SSL;
References
For information about how to grant privileges to a user, see Directly grant privileges.
You can view the information about the created user in the
dba_userstable. For more information about thedba_userstable, see DBA_USERS.For information about how to connect to OceanBase Database using the created user, see Connect to OceanBase Database.
