Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Postgres: Complete DELETE FROM grammar (#2791)
* Postgres: Complete DELETE FROM grammar * Add DELETE statement to WITH grammar * Add WITH RECURSIVE example Co-authored-by: Barry Pollard <barry@tunetheweb.com>
- Loading branch information
1 parent
9717038
commit c19c5b2
Showing
4 changed files
with
411 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
DELETE FROM films WHERE kind <> 'Musical'; | ||
|
||
DELETE FROM films; | ||
|
||
DELETE FROM tasks WHERE status = 'DONE' RETURNING *; | ||
DELETE FROM ONLY films; | ||
|
||
DELETE FROM films *; | ||
|
||
DELETE FROM films AS f; | ||
|
||
DELETE FROM films USING producers | ||
WHERE producer_id = producers.id AND producers.name = 'foo'; | ||
|
||
DELETE FROM films AS f USING producers AS p | ||
WHERE f.producer_id = p.id AND p.name = 'foo'; | ||
|
||
DELETE FROM films AS f USING producers AS p, actors AS a | ||
WHERE f.producer_id = p.id AND p.name = 'foo' | ||
AND f.actor_id = a.id AND a.name = 'joe cool'; | ||
|
||
DELETE FROM tasks WHERE CURRENT OF c_tasks; | ||
|
||
DELETE FROM some_table | ||
USING other_table | ||
WHERE other_table.col = some_table.col | ||
DELETE FROM films WHERE kind <> 'Musical'; | ||
|
||
DELETE FROM tasks WHERE status = 'DONE' RETURNING *; | ||
|
||
DELETE FROM tasks WHERE status = 'DONE' RETURNING actor_id; | ||
|
||
DELETE FROM tasks WHERE status = 'DONE' RETURNING actor_id as a_id; | ||
|
||
DELETE FROM tasks WHERE status = 'DONE' RETURNING actor_id, producer_id; | ||
|
||
DELETE FROM tasks WHERE status = 'DONE' RETURNING actor_id as a_id, producer_id as p_id; | ||
|
||
WITH test as (select foo from bar) | ||
DELETE FROM films; | ||
|
||
WITH RECURSIVE t(n) AS ( | ||
VALUES (1) | ||
UNION ALL | ||
SELECT n+1 FROM t WHERE n < 100 | ||
) | ||
DELETE FROM films; |
Oops, something went wrong.