All Products
Search
Document Center

CREATE USER

Last Updated: Jun 18, 2021

Description

This statement creates a new ApsaraDB for OceanBase user. After a user is created, you can use the user to connect to ApsaraDB for OceanBase.

Note

To use the CREATE USER command, you must have the CREATE USER system permission.

Syntax

create_user_stmt:
    CREATE USER user_name [host_name] IDENTIFIED BY password [REQUIRE {NONE | SSL | X509 | tls_option_list}]
 [PROFILE user_profile] [DEFAULT TABLESPACE table_space]

password:
    STR_VALUE
    
tls_option_list:
        tls_option
    | tls_option_list, tls_option
    
tls_option:
          CIPHER STR_VALUE
    | ISSUER STR_VALUE
    | SUBJECT STR_VALUE

Parameter description

Parameter

Description

user_name

The username. After a new user is created, a new row for this user is added to the dba_users table. If the same username already exists, the system reports an error.

host_name

The hostname of the user. The value is in the @xxx.xxx.xx.x format.

IDENTIFIED BY

You must use an IDENTIFIED BY clause. You can specify a password for the account.

REQUIRE

Set the encryption protocol used by the user to NONE, SSL, X509, or tls_option_list.

PROFILE user_profile

Specifies a profile that is used by the user.

DEFAULT TABLESPACE table_space

Specifies the default tablespace for the user.

Examples

  1. Run the following command to create a user named sqluser for which the password is 123456.

CREATE USER sqluser IDENTIFIED BY 123456;
  1. Run the following command to query the created user.

SELECT username FROM dba_users;

The following execution result is displayed:

OceanBase(TEST@TEST)>CREATE USER sqluser IDENTIFIED BY 123456;
Query OK, 0 rows affected (0.05 sec)
OceanBase(TEST@TEST)>SELECT username FROM dba_users;
+------------+
| USERNAME   |
+------------+
| SYS        |
| LBACSYS    |
| ORAAUDITOR |
| ROOT       |
| TEST       |
| ADMIN      |
| SQLUSER    |
+------------+
7 rows in set (0.01 sec)