DELETE
Function
Delete data from an HStore table.

- To use hybrid data warehouse capabilities, choose the storage-compute coupled architecture when you create a GaussDB(DWS) cluster on the console and ensure the vCPU to memory ratio is 1:4 when setting up cloud disk flavors. For more information, see Data Warehouse Flavors.
- When setting up a GaussDB(DWS) cluster, make sure to have a vCPU to memory ratio of 1:8 for standard data warehouses and a ratio of 1:4 for hybrid data warehouses. You can distinguish a standard data warehouse from a real-time data warehouse by comparing their vCPU to memory ratios.
Precautions
- To efficiently remove all data from a table and prevent it from becoming bloated, use the TRUNCATE syntax.
- If a single record is deleted from an HStore table, a record of the type D will be inserted into the delta table. The memory update chain will also be updated to manage concurrency.
- If multiple records are deleted from an HStore table at a time, a record of the type D will be inserted for the consecutive deleted records in each CU.
- In concurrent deletion scenarios, operations on the same CU will get queued in traditional column-store tables and result in low performance. For HStore tables, the operations can be concurrently performed, and the deletion performance can be more than 100 times that of column-store tables.
- The syntax is fully compatible with column storage. For more information, see the UPDATE syntax.
Syntax
1 2 3 |
DELETE FROM [ ONLY ] table_name [ * ] [ [ AS ] alias ] [ USING using_list ] [ WHERE condition ] |
Parameters
- ONLY
If ONLY is specified, only that table is deleted. If ONLY is not specified, this table and all its sub-tables are deleted.
- table_name
Specifies the name (optionally schema-qualified) of a target table.
Value range: an existing table name
- alias
Specifies the alias for the target table.
Value range: a string. It must comply with the naming convention.
- using_list
Specifies the USING clause.
- condition
Specifies an expression that returns a value of type boolean. Only rows for which this expression returns true will be deleted.
Example
1 2 3 4 5 6 7 |
CREATE TABLE reason_t2 ( TABLE_SK INTEGER , TABLE_ID VARCHAR(20) , TABLE_NA VARCHAR(20) )WITH(ORIENTATION=COLUMN, ENABLE_HSTORE=ON); INSERT INTO reason_t2 VALUES (1, 'S01', 'StudentA'),(2, 'T01', 'TeacherA'),(3, 'T02', 'TeacherB'); |
1 2 |
DELETE FROM reason_t2 WHERE TABLE_SK = 2; DELETE FROM reason_t2 AS rt2 WHERE rt2.TABLE_SK = 2; |
1
|
DELETE FROM reason_t2 WHERE TABLE_SK in (1,3); |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.