All Products
Search
Document Center

ApsaraDB for OceanBase:CreateTenantUser

Last Updated:Apr 29, 2024

You can call this operation to create an account in a tenant that has access to a database.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
oceanbase:CreateTenantUserWRITE
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
TenantIdstringYes

The ID of the tenant.

ob2mr3oae0****
UserNamestringYes

The name of the database account. You cannot use reserved keywords, such as SYS and root.

pay_test
UserTypestringYes

The type of the database account. Valid values: Admin: the super administrator account. Normal: a general account.

Normal
UserPasswordstringYes

The password of the database account. It must be 10 to 32 characters in length and contain three types of the following characters: uppercase letters, lowercase letters, digits, and special characters. The special characters are ! @ # $ % \ ^ \ & \ * ( ) _ + - =

!Aliyun4Oceanbase
RolesstringNo

The role of the user account. In Oracle mode, this parameter unspecified is left unspecified. In MySQL mode, the super administrator account has ALL PRIVILEGES, and you can leave this parameter unspecified. You need to specify the account information for a general user account. By default, the account information is a JSON array that contains the information of the role and the schema (Oracle mode) or database (MySQL mode). Valid values: ReadWrite: a role that has the read and write privileges, namely ALL PRIVILEGES. ReadOnly: a role that has only the read-only privilege SELECT. DDL: a role that has DDL privileges such as CREATE, DROP, ALTER, SHOW VIEW, and CREATE VIEW. DML: a role that has DML privileges such as SELECT, INSERT, UPDATE, DELETE, and SHOW VIEW.

[{"Database":"oceanbase1","Role":"readwrite"},{"Database":"oceanbase2","Role":"readonly"}]
InstanceIdstringYes

The ID of the OceanBase cluster.

ob317v4uif****
DescriptionstringNo

The description of the database.

this is a test database

You can call this operation to create an account in a tenant that has access to a database.

Response parameters

ParameterTypeDescriptionExample
object

The return result of the request.

TenantUserobject []

The list of database accounts in the tenant.

UserTypestring

The type of the database account. Valid values: - Admin: the super administrator account. - Normal: a general account.

Normal
Rolesobject []

The roles of the accounts.

Databasestring

The name of the database.

db_pay1
Rolestring

The role of the account. In Oracle mode, a role is a schema-level role. Valid values: - ReadWrite: a role that has the read and write privileges, including CREATE TABLE, CREATE VIEW, CREATE PROCEDURE, CREATE SYNONYM, CREATE SEQUENCE, CREATE TRIGGER, CREATE TYPE, CREATE SESSION, EXECUTE ANY PROCEDURE, CREATE ANY OUTLINE, ALTER ANY OUTLINE, DROP ANY OUTLINE, CREATE ANY PROCEDURE, ALTER ANY PROCEDURE, DROP ANY PROCEDURE, CREATE ANY SEQUENCE, ALTER ANY SEQUENCE, DROP ANY SEQUENCE, CREATE ANY TYPE, ALTER ANY TYPE, DROP ANY TYPE, SYSKM, CREATE ANY TRIGGER, ALTER ANY TRIGGER, DROP ANY TRIGGER, CREATE PROFILE, ALTER PROFILE, and DROP PROFILE. - ReadOnly: a role that has only the read-only privilege SELECT. In MySQL mode, a role is a database-level role. Valid values: - ReadWrite: a role that has the read and write privileges, namely ALL PRIVILEGES. - ReadOnly: a role that has only the read-only privilege SELECT. - DDL: a role that has the DDL privileges such as CREATE, DROP, ALTER, SHOW VIEW, and CREATE VIEW. - DML: a role that has the DML privileges such as SELECT, INSERT, UPDATE, DELETE, and SHOW VIEW.

  • By default, an Oracle account has the read and write privileges on its own schema, which are not listed here.
ReadOnly
UserStatusstring

The status of the database account. Valid values: - Locked: The account is locked. - ONLINE: The account is unlocked. The default status of a new account is ONLINE after it is created.

ONLINE
UserNamestring

The name of the database account.

pay_test
RequestIdstring

The request ID.

EE205C00-30E4-XXXX-XXXX-87E3A8A2AA0C

Examples

Sample success responses

JSONformat

{
  "TenantUser": [
    {
      "UserType": "Normal",
      "Roles": [
        {
          "Database": "db_pay1",
          "Role": "ReadOnly"
        }
      ],
      "UserStatus": "ONLINE",
      "UserName": "pay_test"
    }
  ],
  "RequestId": "EE205C00-30E4-XXXX-XXXX-87E3A8A2AA0C"
}

Error codes

HTTP status codeError codeError message
500InternalErrorThe request processing has failed due to some unknown error.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-12-26The Error code has changed. The response structure of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 500
Output ParametersThe response structure of the API has changed.
2023-07-04The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 500
2023-04-06The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 500
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: EncryptionType