CLEAR_BALANCE_WEIGHT is used to clear the partition weight.
Limitations and considerations
Only user tenants can call the
CLEAR_BALANCE_WEIGHTprocedure to clear the partition weight. System tenants cannot clear the partition weight.Clearing the table-level partition weight deletes all table-level weights set on the partitions. If partition-level weights have been set for the table, they will be retained.
Syntax
DBMS_BALANCE.CLEAR_BALANCE_WEIGHT(
database_name VARCHAR(65535),
table_name VARCHAR(65535),
partition_name VARCHAR(65535) DEFAULT NULL,
subpartition_name VARCHAR(65535) DEFAULT NULL);
Parameters
| Parameter | Description |
|---|---|
| database_name | The name of the database to which the table belongs. |
| table_name | The name of the table. |
| partition_name | The name of the primary partition. |
| subpartition_name | The name of the subpartition. This parameter is supported only in syntax and cannot be used to set the subpartition weight. |
Examples
Assume that the
testdatabase of the user contains a tabletbl1_hwith a partition weight set.Query the partition weight information. The statement is as follows:
obclient(root@mysql001)[test]> SELECT * FROM oceanbase.DBA_OB_OBJECT_BALANCE_WEIGHT;The query result is as follows:
+----------+--------------+-----------------+--------+---------------+------------+----------------+-------------------+-----------------+-------------+---------------+-----------+ | TABLE_ID | PARTITION_ID | SUBPARTITION_ID | WEIGHT | DATABASE_NAME | TABLE_NAME | PARTITION_NAME | SUBPARTITION_NAME | TABLEGROUP_NAME | DATABASE_ID | TABLEGROUP_ID | OBJECT_ID | +----------+--------------+-----------------+--------+---------------+------------+----------------+-------------------+-----------------+-------------+---------------+-----------+ | 500002 | NULL | NULL | 1 | test | tbl1_h | NULL | NULL | NULL | 500001 | NULL | 500002 | | 500002 | 500003 | NULL | 2 | test | tbl1_h | p0 | NULL | NULL | 500001 | NULL | 500003 | +----------+--------------+-----------------+--------+---------------+------------+----------------+-------------------+-----------------+-------------+---------------+-----------+ 2 rows in setClear the table-level partition weight for the table
tbl1_h.obclient(root@mysql001)[test]> CALL DBMS_BALANCE.CLEAR_BALANCE_WEIGHT('test','tbl1_h');Query the partition weight information set for the table after clearing.
obclient(root@mysql001)[test]> SELECT * FROM oceanbase.DBA_OB_OBJECT_BALANCE_WEIGHT;The query result is as follows:
+----------+--------------+-----------------+--------+---------------+------------+----------------+-------------------+-----------------+-------------+---------------+-----------+ | TABLE_ID | PARTITION_ID | SUBPARTITION_ID | WEIGHT | DATABASE_NAME | TABLE_NAME | PARTITION_NAME | SUBPARTITION_NAME | TABLEGROUP_NAME | DATABASE_ID | TABLEGROUP_ID | OBJECT_ID | +----------+--------------+-----------------+--------+---------------+------------+----------------+-------------------+-----------------+-------------+---------------+-----------+ | 500002 | 500003 | NULL | 2 | test | tbl1_h | p0 | NULL | NULL | 500001 | NULL | 500003 | +----------+--------------+-----------------+--------+---------------+------------+----------------+-------------------+-----------------+-------------+---------------+-----------+ 1 row in setClear the partition weight for the primary partition
p0in the tabletbl1_h.obclient(root@mysql001)[test]> CALL DBMS_BALANCE.CLEAR_BALANCE_WEIGHT('test','tbl1_h','p0');Query the partition weight information set for the table again after clearing.
obclient(root@mysql001)[test]> SELECT * FROM oceanbase.DBA_OB_OBJECT_BALANCE_WEIGHT;The query result is empty.