Delete Statement
The delete_statement node represents a SQL DELETE statement, used to remove records from a table.
Structure
| <xs:element name="delete_statement">
<xs:complexType>
<xs:sequence>
<xs:element name="cte_list" type="cte_list_type" minOccurs="0"/>
<xs:element name="top_clause" type="top_row_filter_type" minOccurs="0"/>
<xs:element name="target_table" type="table_reference_type"/>
<xs:element ref="from_clause" minOccurs="0"/>
<xs:element ref="where_clause" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
|
Elements
| Element |
Type |
Description |
cte_list |
cte_list_type |
Represents a Common Table Expression (CTE). Optional. |
top_clause |
top_row_filter_type |
Specifies a row limit for deletion (e.g., TOP (10)). Optional. |
target_table |
table_reference_type |
The table from which to delete rows. Required. |
from_clause |
from_clause |
Specifies additional tables for filtering. Optional. |
where_clause |
where_clause |
The condition that determines which rows to delete. Optional. If omitted, all rows are deleted. |
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | <statement type="delete_statement">
<target_table type="named_table_reference">
<named_table_reference>
<table_name>
<full_name>employees</full_name>
<object_name>employees</object_name>
</table_name>
</named_table_reference>
</target_table>
<where_clause>
<condition expr_type="comparison_expr">
<comparison_expr type="=">
<first_expr expr_type="column_referenced_expr">
<objectName>
<full_name>department</full_name>
<object_name>department</object_name>
</objectName>
</first_expr>
<second_expr expr_type="constant_expr">
<literal>
<value>'HR'</value>
</literal>
</second_expr>
</comparison_expr>
</condition>
</where_clause>
</statement>
|