DELETE statement with subquery operates in the same way, as DELETE statement with a simple condition in WHERE clause.
It deletes from a relational table all rows, that satisfy a condition in WHERE clause.
The only difference, is such that a condition in WHERE clause includes a number of subqueries.
A diagram given in the present slide explains a situation where we would like to delete from a relational table: TABLE 1, all rows, that have a value in column: COLUMN 1, included in a set of values from a column: COLUMN 2, that satisfy a condition: Condition 2, in a relational table: TABLE 2.
DELETE statement is interpreted in the following way.
If a subquery does not contain the references to a relational table: TABLE 1, then it is processed first and the results are saved as the results of processing of an inline view.
Next, a relational table: TABLE 1, is read row by row and a condition in WHERE clause is evaluated for each row.
If a value in a column: COLUMN 2, in the current row is included in the results of processing of inline view, then the condition evaluates to true.
If evaluation of a condition in WHERE clause returns true, then the current row is deleted from a relational table TABLE 1.
If a subquery contains the references to a relational table: TABLE 1, then the table is read row by row and like with the correlated nested queries, the references are replaced with the values from the respective rows taken from a TABLE 1.
Then, a subquery is processed for the current row and the results are stored in an inline view.
Next, a condition in WHERE clause is evaluated.
If evaluation of a condition in WHERE clause returns true, then the current row is deleted from a relational table TABLE 1.
Next, the same procedure is repeated for each row in a relational table: TABLE 1.
DELETE statement with subquery is a data manipulation language statement and its outcomes can be reversed with ROLLBACK statement.