Skip to content

Commit e2efa55

Browse files
committed
Document DELETE syntax
1 parent ff26895 commit e2efa55

File tree

3 files changed

+114
-1
lines changed

3 files changed

+114
-1
lines changed

sql/delete.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# DELETE statement
2+
3+
[SQL standard][] specifies the following DELETE syntax:
4+
5+
DELETE FROM { table_name | ONLY "(" table_name ")" } [[AS] alias]
6+
[WHERE condition | WHERE CURRENT OF cursor_name]
7+
8+
This base syntax is pretty well supported (except in Spark):
9+
10+
[BigQuery][]:
11+
12+
DELETE [FROM] table_name [alias]
13+
WHERE condition
14+
15+
[DB2][]:
16+
17+
DELETE FROM { table_name | ONLY "(" table_name ")" | "(" fullselect ")" }
18+
[[AS] correlation_clause]
19+
[INCLUDE include_columns]
20+
[assignment_clause]
21+
[WHERE condition | WHERE CURRENT OF cursor_name]
22+
[WITH {RR | RS | CS | UR}]
23+
24+
[Hive][]:
25+
26+
DELETE FROM table_name
27+
[WHERE condition]
28+
29+
[MariaDB][]:
30+
31+
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM table_name
32+
[PARTITION "(" partition_list ")"]
33+
[FOR PORTION OF period FROM expr1 TO expr2]
34+
[FROM from_clause]
35+
[USING using_clause]
36+
[WHERE condition]
37+
[ORDER BY ...]
38+
[LIMIT row_count]
39+
[RETURNING returning_clause]
40+
41+
[MySQL][]:
42+
43+
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM table_name [[AS] alias]
44+
[PARTITION "(" partition_list ")"]
45+
[WHERE condition]
46+
[ORDER BY ...]
47+
[LIMIT row_count]
48+
49+
[N1QL][]:
50+
51+
DELETE FROM table_name
52+
[USE [PRIMARY] KEYS expr]
53+
[WHERE condition]
54+
[LIMIT expr]
55+
[RETURNING returning_clause]
56+
57+
[PL/SQL][]:
58+
59+
DELETE [hint] FROM { table_name | ONLY "(" table_name ")" } [alias]
60+
[WHERE condition]
61+
[[RETURN | RETURNING] returning_clause]
62+
[LOG ERRORS error_logging_clause]
63+
64+
[PostgreSQL][]:
65+
66+
[WITH [RECURSIVE] with_clause]
67+
DELETE FROM [ONLY] table_name [ * ] [[AS] alias]
68+
[USING from_items]
69+
[WHERE condition | WHERE CURRENT OF cursor_name]
70+
[RETURNING returning_clause]
71+
72+
[Redshift][]:
73+
74+
[WITH [RECURSIVE] with_clause]
75+
DELETE [FROM] table_name
76+
[USING from_items]
77+
[WHERE condition]
78+
79+
[Spark][]:
80+
81+
_No support for DELETE_
82+
83+
[SQLite][]:
84+
85+
[WITH [RECURSIVE] with_clause]
86+
DELETE FROM table_name
87+
[FROM from_clause]
88+
[WHERE condition]
89+
[RETURNING returning_clause]
90+
91+
[Transact-SQL][]:
92+
93+
[WITH with_clause]
94+
DELETE [TOP ( expression ) [PERCENT]] FROM table_name
95+
[FROM from_clause]
96+
[WHERE condition | WHERE CURRENT OF [GLOBAL] cursor_name]
97+
[OPTION query_hints]
98+
99+
[sql standard]: https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_14_8_delete_statement_searched
100+
[bigquery]: https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#delete_statement
101+
[db2]: https://www.ibm.com/docs/en/db2/9.7?topic=statements-delete
102+
[hive]: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Delete
103+
[mariadb]: https://mariadb.com/kb/en/delete/
104+
[mysql]: https://dev.mysql.com/doc/refman/8.0/en/delete.html
105+
[n1ql]: https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/delete.html
106+
[pl/sql]: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/DELETE.html
107+
[postgresql]: https://www.postgresql.org/docs/current/sql-delete.html
108+
[redshift]: https://docs.aws.amazon.com/redshift/latest/dg/r_DELETE.html
109+
[spark]: https://spark.apache.org/docs/latest/sql-ref-syntax.html#dml-statements
110+
[sqlite]: https://www.sqlite.org/lang_delete.html
111+
[transact-sql]: https://docs.microsoft.com/en-us/sql/t-sql/statements/delete-transact-sql?view=sql-server-ver16

sql/syntax.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ Reference of SQL syntax variations.
1010
- [SELECT](./select.md)
1111
- [INSERT](./insert.md)
1212
- [UPDATE](./update.md)
13+
- [DELETE](./delete.md)
1314
- [CREATE TABLE](./create-table.md)
1415
- [CREATE VIEW](./create-view.md)

sql/update.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ This base syntax is pretty well supported (except in Spark):
1818
[DB2][]:
1919

2020
UPDATE { table_name | ONLY "(" table_name ")" | "(" fullselect ")" }
21-
[correlation_clause] [include_columns]
21+
[[AS] correlation_clause]
22+
[INCLUDE include_columns]
2223
SET set_clause_list
2324
[WHERE condition | WHERE CURRENT OF cursor_name]
2425
[WITH {RR | RS | CS | UR}]

0 commit comments

Comments
 (0)