Purpose
This statement is used to drop a table group.
Notice
If any table's TABLEGROUP attribute references the target table group, the table group cannot be dropped.
Privilege requirements
To execute DROP TABLEGROUP, you need the following privileges:
- You must have the
DROPprivilege to drop a table group. - If the table group contains tables, you need the
ALTERprivilege on those tables to modify their table group attributes.
Considerations
- Dropping a table group does not delete the tables within it, but it removes the association between the tables and the table group.
- Before dropping a table group, ensure that no business processes depend on it.
Syntax
DROP TABLEGROUP tablegroup_name
Parameters
| Parameter | Description |
|---|---|
| tablegroup_name | The name of the table group to be dropped. |
Examples
Example 1: Drop a referenced table group
When a table group is referenced by tables through the TABLEGROUP attribute, you need to remove these references before dropping the table group.
Attempting to drop a non-empty table group 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
tblgroup1table group:obclient> SHOW TABLEGROUPS; obclient> SHOW TABLES IN tblgroup1;Remove the
tbl1table from thetblgroup1table group:obclient> ALTER TABLE tbl1 SET TABLEGROUP = '';Drop the
tblgroup1table group again:obclient> DROP TABLEGROUP tblgroup1;
Example 2: Complete table group usage process
Create a table group:
obclient> CREATE TABLEGROUP tg1;Create a table and specify the table group:
obclient> CREATE TABLE t1 (id INT) TABLEGROUP = tg1;View the table group information:
obclient> SHOW TABLEGROUPS;Remove the
t1table from thetg1table group:obclient> ALTER TABLE t1 SET TABLEGROUP = '';Drop the
tg1table group:obclient> DROP TABLEGROUP tg1;