You can query tenant information by using an SQL statement.
View information of all tenants
In the sys tenant, you can query the oceanbase.DBA_OB_TENANTS view for information of tenants in the cluster, including the ID, name, primary zone, and replica distribution of each tenant.
Log on to the
systenant as therootuser.Execute the following statement to query information of tenants in the current cluster.
Sample code:
obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS\G *************************** 1. row *************************** TENANT_ID: 1 TENANT_NAME: sys TENANT_TYPE: SYS CREATE_TIME: 2023-02-06 11:50:21.843349 MODIFY_TIME: 2023-02-06 11:51:17.054689 PRIMARY_ZONE: zone1 LOCALITY: FULL{1}@zone1 PREVIOUS_LOCALITY: NULL COMPATIBILITY_MODE: MYSQL STATUS: NORMAL IN_RECYCLEBIN: NO LOCKED: NO TENANT_ROLE: PRIMARY SWITCHOVER_STATUS: NORMAL SWITCHOVER_EPOCH: 0 SYNC_SCN: NULL REPLAYABLE_SCN: NULL READABLE_SCN: NULL RECOVERY_UNTIL_SCN: NULL LOG_MODE: NOARCHIVELOG ARBITRATION_SERVICE_STATUS: DISABLED *************************** 2. row *************************** TENANT_ID: 1001 TENANT_NAME: META$1002 TENANT_TYPE: META CREATE_TIME: 2023-02-06 13:38:03.410324 MODIFY_TIME: 2023-02-06 13:38:19.535303 PRIMARY_ZONE: zone1 LOCALITY: FULL{1}@zone1 PREVIOUS_LOCALITY: NULL COMPATIBILITY_MODE: MYSQL STATUS: NORMAL IN_RECYCLEBIN: NO LOCKED: NO TENANT_ROLE: PRIMARY SWITCHOVER_STATUS: NORMAL SWITCHOVER_EPOCH: 0 SYNC_SCN: NULL REPLAYABLE_SCN: NULL READABLE_SCN: NULL RECOVERY_UNTIL_SCN: NULL LOG_MODE: NOARCHIVELOG ARBITRATION_SERVICE_STATUS: DISABLED *************************** 3. row *************************** TENANT_ID: 1002 TENANT_NAME: mysql001 TENANT_TYPE: USER CREATE_TIME: 2023-02-06 13:38:03.416572 MODIFY_TIME: 2023-02-06 13:38:19.565811 PRIMARY_ZONE: zone1 LOCALITY: FULL{1}@zone1 PREVIOUS_LOCALITY: NULL COMPATIBILITY_MODE: MYSQL STATUS: NORMAL IN_RECYCLEBIN: NO LOCKED: NO TENANT_ROLE: PRIMARY SWITCHOVER_STATUS: NORMAL SWITCHOVER_EPOCH: 0 SYNC_SCN: 1678328804810378183 REPLAYABLE_SCN: 1678328804810378183 READABLE_SCN: 1678328804601007064 RECOVERY_UNTIL_SCN: 4611686018427387903 LOG_MODE: NOARCHIVELOG ARBITRATION_SERVICE_STATUS: DISABLED 3 rows in setFor more information about the fields in the
oceanbase.DBA_OB_TENANTSview, see DBA_OB_TENANTS.
View information of the current tenant
All users can view information of the current tenant, including the name, ID, and status of the tenant.
Log on to a user tenant of the database.
Execute the following statement to query information of the current tenant.
Sample code:
obclient [SYS]> SELECT * FROM DBA_OB_TENANTS; *************************** 1. row *************************** TENANT_ID: 1004 TENANT_NAME: oracle001 TENANT_TYPE: USER CREATE_TIME: 13-MAR-23 10.23.07.538516 AM MODIFY_TIME: 13-MAR-23 10.23.25.073040 AM PRIMARY_ZONE: zone1 LOCALITY: FULL{1}@zone1 PREVIOUS_LOCALITY: NULL COMPATIBILITY_MODE: ORACLE STATUS: NORMAL IN_RECYCLEBIN: NO LOCKED: NO TENANT_ROLE: PRIMARY SWITCHOVER_STATUS: NORMAL SWITCHOVER_EPOCH: 0 SYNC_SCN: 1679392361895209460 REPLAYABLE_SCN: 1679392361895209460 READABLE_SCN: 1679392361804500893 RECOVERY_UNTIL_SCN: 4611686018427387903 LOG_MODE: NOARCHIVELOG 1 row in set