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.
Note
You must have the CREATE USER system privilege to use the CREATE USER statement.
Syntax
create_user_stmt:
CREATE USER user_name [host_name] IDENTIFIED BY [ VALUES ] password_str
[REQUIRE {NONE | SSL | X509 | tls_option_list}]
[PROFILE user_profile]
[DEFAULT TABLESPACE table_space]
tls_option_list:
tls_option
| tls_option_list, tls_option
tls_option:
CIPHER STR_VALUE
| ISSUER STR_VALUE
| SUBJECT STR_VALUE
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. |
| host_name | The name of the host where the user is located, which is in the format of @xxx.xxx.xx.x. |
| IDENTIFIED BY | You must use the IDENTIFIED BY clause to specify a password for the user. IDENTIFIED BY VALUES password_str specifies a password in ciphertext. If the password contains special characters ~!@#%^&*_-+=`|(){}[]:;',.?/, it must be enclosed in double quotation marks. |
| REQUIRE | The encryption protocol for the user. Valid values: NONE, SSL, X509, and tls_option_list. |
| PROFILE user_profile | The profile used by the user. |
| DEFAULT TABLESPACE table_space | The default tablespace for the user. |
Examples
Create a user named
user1and specify a password in plaintext for the user.obclient> CREATE USER user1 IDENTIFIED BY ******; Query OK, 0 rows affectedCreate a user named
user2and specify a password in ciphertext for the user.obclient> CREATE USER user2 IDENTIFIED BY VALUES "**********************************"; Query OK, 0 rows affectedQuery the users that you created.
obclient> SELECT username FROM dba_users; +------------+ | USERNAME | +------------+ | SYS | | LBACSYS | | ORAAUDITOR | | PUBLIC | | USER1 | | USER2 | +------------+ 6 rows in set