Purpose
You can use this statement to losslessly switch a tenant of the primary role to one of a standby role and the other way around.
Syntax
ALTER SYSTEM SWITCHOVER TO
STANDBY | PRIMARY [TENANT tenant_name]
Note
- You must specify the
TENANT tenant_nameparameter when you execute this statement in the `sys` tenant. - In a user tenant, you can execute this statement only for the current tenant.
Parameters
| Parameter | Description |
|---|---|
| STANDBY | Losslessly switches the primary tenant to be a standby tenant. |
| PRIMARY | Switches the standby tenant to be the primary tenant. |
| tenant_name | The name of the primary or standby tenant. |
Examples
Switch the primary tenant to be a standby tenant named tenant1, and verify that the value of TENANT_ROLE has changed to STANDBY and the value of SWITCHOVER_STATUS has changed to NORMAL.
obclient> ALTER SYSTEM SWITCHOVER TO STANDBY TENANT tenant1;
Query OK, 0 rows affected
obclient> SELECT TENANT_NAME,TENANT_TYPE,TENANT_ROLE,SWITCHOVER_STATUS FROM DBA_OB_TENANTS
WHERE TENANT_NAME='tenant1';
+---------------------+-------------+-------------+-------------------+
| TENANT_NAME | TENANT_TYPE | TENANT_ROLE | SWITCHOVER_STATUS |
+---------------------+-------------+-------------+-------------------+
| t1 | USER | STANDBY | NORMAL |
+---------------------+-------------+-------------+-------------------+
1 row in set