DELETE FROMtable_identifier
USING {stream_identifier
|stream_expression
} WHEREpredicate
[RETURNINGtarget_list
] [ERROR INTOstream_identifier
];
-
table_identifier
-
The unique identifier (name) of the table from which to delete rows.
-
stream_identifier
-
The unique identifier (name) of the stream whose tuples contain the values that will be used to delete rows from the table.
-
stream_expression
-
A StreamSQL statement that produces a stream whose tuples contain the values that will be used to delete rows from the table. The statement must be enclosed within parentheses.
-
predicate
-
The logic used to select specific table content.
-
target_list
-
One or more entries, separated by commas, of the format target_list_entry.
-
target_list_entry
-
A value, of the format scalar_expression [AS output_field_identifier], to be included in the result set returned by the statement.
-
scalar_expression
-
An expression that generates a value for a tuple field that is returned by the delete operation. Values can be obtained from an input tuple field, from a simple function or from the table. Optionally, the name for a value can be modified through an AS clause.
-
output_field_identifier
-
A unique identifier (name) for the tuple field that contains a value returned by the delete operation.
You can append an ERROR INTO clause just before the closing semicolon. The StreamSQL ERROR INTO clause is analogous to the Enable Error Output Port check box for operators and adapters in EventFlow applications.
Use ERROR INTO with the name of a stream, which must already exist. This sets up an Error Port for this operator, which is much like a local catch mechanism for errors from this operator.
See Using Error Ports and Error Streams for a discussion of StreamBase error handling mechanisms.
The DELETE statement removes a row, or rows, from an existing table.
With the DELETE statement, the USING clause identifies the stream whose tuples contain the values that will be used to identify the rows that will be deleted from the table. Since multiple rows can be deleted, the optional ORDER BY [DESC] LIMIT number clause provides a way to limit the number of rows affected and to organize the result set generated by the RETURNING clause.
In the RETURNING clause, scalar_expression
can specify a value from the stream and/or from the table. For example:
DELETE ... RETURNINGtuple_field_identifier
[AS...
][, ...
],column_identifier
[AS...
][, ...
]
The result set generated by the RETURNING clause must be captured into a stream. You can use the CREATE STREAM statement to define a stream and the INTO keyword to populate the stream with the content generated by the RETURNING clause. As an alternative, in a single statement use the => (arrow) operator with a CREATE STREAM statement, as illustrated below.
CREATE STREAMstream_identifier
; DELETE...
RETURNING...
INTOstream_identifier
;
Or
DELETE...
RETURNING...
=> CREATE STREAMstream_identifier