Purpose
You can use this statement to create an OceanBase Database user. After you create a user, you can use it to connect to OceanBase Database.
Limitations and considerations
- Authentication string format validation:
IDENTIFIED WITH ... BY VALUESis validated against the$S$format. Invalid formats such as$A$(e.g.,sha2) are rejected. - An incompatible ODP cannot establish connections for SM3 users (users using the authentication plugin
ob_sm3_password).
Required privileges
You must have the CREATE USER system privilege to use the CREATE USER statement. For more information about OceanBase Database privileges, see Privilege types in Oracle-compatible mode.
Syntax
CREATE USER user_name
{ IDENTIFIED BY [VALUES] password
| IDENTIFIED WITH auth_plugin [BY password]
}
[REQUIRE {NONE | SSL | X509 | tls_option}]
[PROFILE profile_name]
[DEFAULT TABLESPACE tablespace_name];
auth_plugin:
caching_sha2_password
| ob_sm3_password
tls_option:
CIPHER cipher_name
| ISSUER issuer_name
| SUBJECT subject_name
Parameters
Parameter |
Description |
|---|---|
| user_name | The username. For each user created, a new entry is created in the dba_users table. If the username already exists, an error is returned. |
| IDENTIFIED BY | The password in plaintext for the user, which is then saved to the dba_users table in ciphertext. If the password contains special characters, it must be enclosed in double quotation marks ("). Special characters are ~!@#%^&*_-+=`|(){}[]:;',.?/. |
| IDENTIFIED BY VALUES | The password in ciphertext for the user, which is saved to the dba_users table directly. |
| IDENTIFIED WITH auth_plugin [BY password] | Specifies the authentication plugin and corresponding authentication information.
NoteFor V4.4.2, the |
| REQUIRE | The authentication requirements for the user. Valid values:
|
| tls_option | The options for TLS requirements. Valid values:
|
| PROFILE | The user profile, which is a set of predefined privileges and restrictions applicable to the user to be created. |
| DEFAULT TABLESPACE | The default tablespace for the user. A tablespace is a logical structure that stores user data. |
auth_plugin
caching_sha2_password: a password-based authentication plugin using SHA-256, providing a higher level of security.Note
For V4.4.2, the authentication plugin
caching_sha2_passwordis supported starting from V4.4.2 BP2.ob_sm3_password: This plugin fully reuses thecaching_sha2_passwordprotocol and state machine (AuthSwitch, fast/authenticating/full-authenticating, TLS/RSA key-passing), but keeps its algorithm and metadata independent. It uses the SM3 hash algorithm instead of SHA-256 for password storage and authentication verification.Note
For V4.4.2, the authentication plugin
ob_sm3_passwordis supported starting from V4.4.2 BP3.
Examples
Create a user named
test1and specify a plaintext password.obclient [SYS]> CREATE USER test1 IDENTIFIED BY "********";Create a user named
test2, specify a ciphertext password, and specify that the user must use an SSL connection for authentication.obclient [SYS]> CREATE USER test2 IDENTIFIED BY VALUES "********" REQUIRE SSL;Create the user
test3and explicitly specify to use thecaching_sha2_passwordauthentication plugin.obclient [SYS]> CREATE USER test3 IDENTIFIED WITH caching_sha2_password BY "********";
References
For more information about how to grant user privileges, see Grant direct privileges.
You can query the information about the created user in the
dba_userstable. For more information about thedba_userstable, see DBA_USERS.For more information about how to use the created user to connect to OceanBase Database, see Connect to OceanBase Database.
For more information about using the default authentication plugin when creating a new user, see default_authentication_plugin.
For more information about authentication plugins, see Authentication.