Purpose
This statement is used to drop a tablegroup.
Notice
If any table's TABLEGROUP attribute references the target tablegroup, the tablegroup cannot be dropped.
Privilege requirements
To execute DROP TABLEGROUP, you need the following privileges:
- You need the
DROPprivilege to drop a tablegroup. - If the tablegroup contains tables, you need the
ALTERprivilege on those tables to modify their tablegroup attribute.
Considerations
- Dropping a tablegroup does not delete the tables within it, but it removes the association between the tables and the tablegroup.
- Before dropping a tablegroup, ensure that no business processes depend on it.
Syntax
DROP TABLEGROUP tablegroup_name
Parameters
| Parameter | Description |
|---|---|
| tablegroup_name | The name of the tablegroup to be dropped. |
Examples
Example 1: Drop a referenced tablegroup
When a tablegroup is referenced by tables through the TABLEGROUP attribute, you need to remove these references before dropping the tablegroup.
Attempting to drop a non-empty tablegroup will result in an error:
obclient> DROP TABLEGROUP tblgroup1;Expected return result:
OBE-00600: internal error code, arguments: -4615, tablegroup is not emptyView the tables in the
tblgroup1tablegroup:obclient> SHOW TABLEGROUPS; obclient> SHOW TABLES IN tblgroup1;Remove the
tbl1table from thetblgroup1tablegroup:obclient> ALTER TABLE tbl1 SET TABLEGROUP = '';Drop the
tblgroup1tablegroup again:obclient> DROP TABLEGROUP tblgroup1;
Example 2: Complete tablegroup usage process
Create a tablegroup:
obclient> CREATE TABLEGROUP tg1;Create a table and specify the tablegroup:
obclient> CREATE TABLE t1 (id INT) TABLEGROUP = tg1;View the tablegroup information:
obclient> SHOW TABLEGROUPS;Remove the
t1table from thetg1tablegroup:obclient> ALTER TABLE t1 SET TABLEGROUP = '';Drop the
tg1tablegroup:obclient> DROP TABLEGROUP tg1;
