@enjoys/context-engine 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/commands/dockerfile.json +66 -0
- package/data/commands/lua.json +66 -0
- package/data/commands/manifest.json +54 -24
- package/data/commands/sql.json +34 -0
- package/data/completion/caddy.json +1589 -0
- package/data/completion/dockerfile.json +1062 -313
- package/data/completion/lua.json +2283 -617
- package/data/completion/nginx.json +804 -1
- package/data/completion/redis-cli.json +3405 -0
- package/data/completion/sql.json +2684 -552
- package/data/defination/caddy.json +428 -0
- package/data/defination/dockerfile.json +211 -29
- package/data/defination/lua.json +875 -125
- package/data/defination/nginx.json +164 -1
- package/data/defination/redis-cli.json +1853 -0
- package/data/defination/sql.json +998 -326
- package/data/hover/caddy.json +458 -0
- package/data/hover/dockerfile.json +180 -42
- package/data/hover/lua.json +775 -69
- package/data/hover/nginx.json +760 -0
- package/data/hover/redis-cli.json +1088 -0
- package/data/hover/sql.json +1119 -76
- package/data/manifest.json +27 -3
- package/package.json +1 -1
package/data/completion/sql.json
CHANGED
|
@@ -4,884 +4,3016 @@
|
|
|
4
4
|
{
|
|
5
5
|
"label": "SELECT",
|
|
6
6
|
"kind": 14,
|
|
7
|
-
"detail": "Select
|
|
8
|
-
"documentation": {
|
|
9
|
-
|
|
7
|
+
"detail": "Select statement",
|
|
8
|
+
"documentation": {
|
|
9
|
+
"value": "Retrieve data from one or more tables.\n\n```sql\nSELECT name, email FROM users WHERE active = true;\n```"
|
|
10
|
+
},
|
|
11
|
+
"insertText": "SELECT ${1:columns}\nFROM ${2:table}\nWHERE ${3:condition};",
|
|
10
12
|
"insertTextRules": 4,
|
|
11
|
-
"sortText": "
|
|
13
|
+
"sortText": "00_select"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"label": "SELECT WHERE",
|
|
17
|
+
"kind": 15,
|
|
18
|
+
"detail": "Select with WHERE",
|
|
19
|
+
"documentation": {
|
|
20
|
+
"value": "Query with a filter condition.\n\n```sql\nSELECT * FROM orders WHERE status = 'shipped';\n```"
|
|
21
|
+
},
|
|
22
|
+
"insertText": "SELECT ${1:*}\nFROM ${2:table}\nWHERE ${3:column} = ${4:'value'};",
|
|
23
|
+
"insertTextRules": 4,
|
|
24
|
+
"sortText": "00_select_where"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"label": "SELECT JOIN",
|
|
28
|
+
"kind": 15,
|
|
29
|
+
"detail": "Select with JOIN",
|
|
30
|
+
"documentation": {
|
|
31
|
+
"value": "Query joining two tables.\n\n```sql\nSELECT u.name, o.total\nFROM users u\nJOIN orders o ON u.id = o.user_id;\n```"
|
|
32
|
+
},
|
|
33
|
+
"insertText": "SELECT ${1:a.column}, ${2:b.column}\nFROM ${3:table1} ${4:a}\nJOIN ${5:table2} ${6:b} ON ${4:a}.${7:id} = ${6:b}.${8:foreign_id};",
|
|
34
|
+
"insertTextRules": 4,
|
|
35
|
+
"sortText": "00_select_join"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"label": "SELECT GROUP BY",
|
|
39
|
+
"kind": 15,
|
|
40
|
+
"detail": "Select with GROUP BY / HAVING",
|
|
41
|
+
"documentation": {
|
|
42
|
+
"value": "Aggregate query with grouping.\n\n```sql\nSELECT department, COUNT(*)\nFROM employees\nGROUP BY department\nHAVING COUNT(*) > 5;\n```"
|
|
43
|
+
},
|
|
44
|
+
"insertText": "SELECT ${1:column}, ${2:COUNT(*)} \nFROM ${3:table}\nGROUP BY ${1:column}\nHAVING ${4:condition};",
|
|
45
|
+
"insertTextRules": 4,
|
|
46
|
+
"sortText": "00_select_group_by"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"label": "SELECT ORDER BY LIMIT",
|
|
50
|
+
"kind": 15,
|
|
51
|
+
"detail": "Select with ORDER BY and LIMIT",
|
|
52
|
+
"documentation": {
|
|
53
|
+
"value": "Sorted and paginated query.\n\n```sql\nSELECT * FROM products ORDER BY price DESC LIMIT 10;\n```"
|
|
54
|
+
},
|
|
55
|
+
"insertText": "SELECT ${1:*}\nFROM ${2:table}\nORDER BY ${3:column} ${4|ASC,DESC|}\nLIMIT ${5:10};",
|
|
56
|
+
"insertTextRules": 4,
|
|
57
|
+
"sortText": "00_select_order_by_limit"
|
|
12
58
|
},
|
|
13
59
|
{
|
|
14
60
|
"label": "SELECT DISTINCT",
|
|
15
61
|
"kind": 15,
|
|
16
|
-
"detail": "Select
|
|
17
|
-
"documentation": {
|
|
18
|
-
|
|
62
|
+
"detail": "Select distinct rows",
|
|
63
|
+
"documentation": {
|
|
64
|
+
"value": "Return only unique rows.\n\n```sql\nSELECT DISTINCT category FROM products;\n```"
|
|
65
|
+
},
|
|
66
|
+
"insertText": "SELECT DISTINCT ${1:columns}\nFROM ${2:table};",
|
|
67
|
+
"insertTextRules": 4,
|
|
68
|
+
"sortText": "00_select_distinct"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"label": "SELECT aliases",
|
|
72
|
+
"kind": 15,
|
|
73
|
+
"detail": "Select with aliases",
|
|
74
|
+
"documentation": {
|
|
75
|
+
"value": "Use column and table aliases.\n\n```sql\nSELECT u.name AS user_name, o.total AS order_total\nFROM users AS u\nJOIN orders AS o ON u.id = o.user_id;\n```"
|
|
76
|
+
},
|
|
77
|
+
"insertText": "SELECT ${1:t}.${2:column} AS ${3:alias}\nFROM ${4:table} AS ${1:t};",
|
|
78
|
+
"insertTextRules": 4,
|
|
79
|
+
"sortText": "00_select_aliases"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"label": "SELECT subquery",
|
|
83
|
+
"kind": 15,
|
|
84
|
+
"detail": "Subquery in SELECT",
|
|
85
|
+
"documentation": {
|
|
86
|
+
"value": "Scalar subquery in the SELECT list.\n\n```sql\nSELECT name,\n (SELECT COUNT(*) FROM orders o WHERE o.user_id = u.id) AS order_count\nFROM users u;\n```"
|
|
87
|
+
},
|
|
88
|
+
"insertText": "SELECT ${1:column},\n (SELECT ${2:COUNT(*)} FROM ${3:table2} ${4:b} WHERE ${4:b}.${5:fk} = ${6:a}.${7:pk}) AS ${8:alias}\nFROM ${9:table1} ${6:a};",
|
|
89
|
+
"insertTextRules": 4,
|
|
90
|
+
"sortText": "00_select_subquery"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"label": "SELECT EXISTS",
|
|
94
|
+
"kind": 15,
|
|
95
|
+
"detail": "EXISTS subquery",
|
|
96
|
+
"documentation": {
|
|
97
|
+
"value": "Check for the existence of rows.\n\n```sql\nSELECT * FROM users u\nWHERE EXISTS (\n SELECT 1 FROM orders o WHERE o.user_id = u.id\n);\n```"
|
|
98
|
+
},
|
|
99
|
+
"insertText": "SELECT ${1:*}\nFROM ${2:table1} ${3:a}\nWHERE EXISTS (\n SELECT 1 FROM ${4:table2} ${5:b}\n WHERE ${5:b}.${6:fk} = ${3:a}.${7:pk}\n);",
|
|
100
|
+
"insertTextRules": 4,
|
|
101
|
+
"sortText": "00_select_exists"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"label": "Correlated subquery",
|
|
105
|
+
"kind": 15,
|
|
106
|
+
"detail": "Correlated subquery",
|
|
107
|
+
"documentation": {
|
|
108
|
+
"value": "Subquery that references the outer query.\n\n```sql\nSELECT e.name, e.salary\nFROM employees e\nWHERE e.salary > (\n SELECT AVG(salary) FROM employees WHERE dept = e.dept\n);\n```"
|
|
109
|
+
},
|
|
110
|
+
"insertText": "SELECT ${1:a}.${2:column}\nFROM ${3:table} ${1:a}\nWHERE ${1:a}.${4:col} ${5:>} (\n SELECT ${6:AGG(col)} FROM ${3:table}\n WHERE ${7:group_col} = ${1:a}.${7:group_col}\n);",
|
|
111
|
+
"insertTextRules": 4,
|
|
112
|
+
"sortText": "00_correlated_subquery"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"label": "SELECT INTO",
|
|
116
|
+
"kind": 15,
|
|
117
|
+
"detail": "Select into new table",
|
|
118
|
+
"documentation": {
|
|
119
|
+
"value": "Create a new table from query results.\n\n```sql\nSELECT * INTO new_table FROM old_table WHERE condition;\n```"
|
|
120
|
+
},
|
|
121
|
+
"insertText": "SELECT ${1:*}\nINTO ${2:new_table}\nFROM ${3:old_table}\nWHERE ${4:condition};",
|
|
122
|
+
"insertTextRules": 4,
|
|
123
|
+
"sortText": "00_select_into"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"label": "INSERT",
|
|
127
|
+
"kind": 14,
|
|
128
|
+
"detail": "Insert statement",
|
|
129
|
+
"documentation": {
|
|
130
|
+
"value": "Insert a row into a table.\n\n```sql\nINSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');\n```"
|
|
131
|
+
},
|
|
132
|
+
"insertText": "INSERT INTO ${1:table} (${2:columns})\nVALUES (${3:values});",
|
|
133
|
+
"insertTextRules": 4,
|
|
134
|
+
"sortText": "00_insert"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"label": "INSERT multiple rows",
|
|
138
|
+
"kind": 15,
|
|
139
|
+
"detail": "Insert multiple rows",
|
|
140
|
+
"documentation": {
|
|
141
|
+
"value": "Insert several rows at once.\n\n```sql\nINSERT INTO products (name, price)\nVALUES ('A', 10), ('B', 20), ('C', 30);\n```"
|
|
142
|
+
},
|
|
143
|
+
"insertText": "INSERT INTO ${1:table} (${2:columns})\nVALUES\n (${3:values1}),\n (${4:values2}),\n (${5:values3});",
|
|
144
|
+
"insertTextRules": 4,
|
|
145
|
+
"sortText": "00_insert_multiple_rows"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"label": "INSERT SELECT",
|
|
149
|
+
"kind": 15,
|
|
150
|
+
"detail": "Insert from select",
|
|
151
|
+
"documentation": {
|
|
152
|
+
"value": "Insert rows from a query.\n\n```sql\nINSERT INTO archive (id, name)\nSELECT id, name FROM users WHERE active = false;\n```"
|
|
153
|
+
},
|
|
154
|
+
"insertText": "INSERT INTO ${1:target} (${2:columns})\nSELECT ${2:columns}\nFROM ${3:source}\nWHERE ${4:condition};",
|
|
155
|
+
"insertTextRules": 4,
|
|
156
|
+
"sortText": "00_insert_select"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"label": "INSERT ON CONFLICT",
|
|
160
|
+
"kind": 15,
|
|
161
|
+
"detail": "Insert on conflict (upsert, PostgreSQL)",
|
|
162
|
+
"documentation": {
|
|
163
|
+
"value": "Upsert using ON CONFLICT.\n\n```sql\nINSERT INTO users (id, name, email)\nVALUES (1, 'Alice', 'a@b.com')\nON CONFLICT (id)\nDO UPDATE SET name = EXCLUDED.name, email = EXCLUDED.email;\n```"
|
|
164
|
+
},
|
|
165
|
+
"insertText": "INSERT INTO ${1:table} (${2:columns})\nVALUES (${3:values})\nON CONFLICT (${4:conflict_column})\nDO UPDATE SET ${5:column} = EXCLUDED.${5:column};",
|
|
166
|
+
"insertTextRules": 4,
|
|
167
|
+
"sortText": "00_insert_on_conflict"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"label": "INSERT ON DUPLICATE KEY",
|
|
171
|
+
"kind": 15,
|
|
172
|
+
"detail": "Insert on duplicate key (MySQL)",
|
|
173
|
+
"documentation": {
|
|
174
|
+
"value": "Upsert using ON DUPLICATE KEY UPDATE.\n\n```sql\nINSERT INTO users (id, name)\nVALUES (1, 'Alice')\nON DUPLICATE KEY UPDATE name = VALUES(name);\n```"
|
|
175
|
+
},
|
|
176
|
+
"insertText": "INSERT INTO ${1:table} (${2:columns})\nVALUES (${3:values})\nON DUPLICATE KEY UPDATE ${4:column} = VALUES(${4:column});",
|
|
177
|
+
"insertTextRules": 4,
|
|
178
|
+
"sortText": "00_insert_on_duplicate_key"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"label": "INSERT RETURNING",
|
|
182
|
+
"kind": 15,
|
|
183
|
+
"detail": "Insert with RETURNING (PostgreSQL)",
|
|
184
|
+
"documentation": {
|
|
185
|
+
"value": "Return inserted data.\n\n```sql\nINSERT INTO users (name) VALUES ('Alice') RETURNING id, name;\n```"
|
|
186
|
+
},
|
|
187
|
+
"insertText": "INSERT INTO ${1:table} (${2:columns})\nVALUES (${3:values})\nRETURNING ${4:*};",
|
|
188
|
+
"insertTextRules": 4,
|
|
189
|
+
"sortText": "00_insert_returning"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"label": "UPDATE",
|
|
193
|
+
"kind": 14,
|
|
194
|
+
"detail": "Update statement",
|
|
195
|
+
"documentation": {
|
|
196
|
+
"value": "Modify existing rows.\n\n```sql\nUPDATE users SET active = false WHERE last_login < '2024-01-01';\n```"
|
|
197
|
+
},
|
|
198
|
+
"insertText": "UPDATE ${1:table}\nSET ${2:column} = ${3:value}\nWHERE ${4:condition};",
|
|
199
|
+
"insertTextRules": 4,
|
|
200
|
+
"sortText": "00_update"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"label": "UPDATE JOIN",
|
|
204
|
+
"kind": 15,
|
|
205
|
+
"detail": "Update with JOIN",
|
|
206
|
+
"documentation": {
|
|
207
|
+
"value": "Update using a joined table.\n\n```sql\nUPDATE orders o\nSET o.status = 'cancelled'\nFROM users u\nWHERE o.user_id = u.id AND u.active = false;\n```"
|
|
208
|
+
},
|
|
209
|
+
"insertText": "UPDATE ${1:table1} ${2:a}\nSET ${2:a}.${3:column} = ${4:value}\nFROM ${5:table2} ${6:b}\nWHERE ${2:a}.${7:fk} = ${6:b}.${8:pk}\n AND ${9:condition};",
|
|
210
|
+
"insertTextRules": 4,
|
|
211
|
+
"sortText": "00_update_join"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"label": "UPDATE subquery",
|
|
215
|
+
"kind": 15,
|
|
216
|
+
"detail": "Update with subquery",
|
|
217
|
+
"documentation": {
|
|
218
|
+
"value": "Update using a subquery.\n\n```sql\nUPDATE products\nSET price = price * 1.1\nWHERE category_id IN (\n SELECT id FROM categories WHERE name = 'Electronics'\n);\n```"
|
|
219
|
+
},
|
|
220
|
+
"insertText": "UPDATE ${1:table}\nSET ${2:column} = ${3:value}\nWHERE ${4:column} IN (\n SELECT ${5:column} FROM ${6:table2} WHERE ${7:condition}\n);",
|
|
221
|
+
"insertTextRules": 4,
|
|
222
|
+
"sortText": "00_update_subquery"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"label": "UPDATE RETURNING",
|
|
226
|
+
"kind": 15,
|
|
227
|
+
"detail": "Update with RETURNING (PostgreSQL)",
|
|
228
|
+
"documentation": {
|
|
229
|
+
"value": "Return updated rows.\n\n```sql\nUPDATE users SET active = true WHERE id = 1 RETURNING *;\n```"
|
|
230
|
+
},
|
|
231
|
+
"insertText": "UPDATE ${1:table}\nSET ${2:column} = ${3:value}\nWHERE ${4:condition}\nRETURNING ${5:*};",
|
|
232
|
+
"insertTextRules": 4,
|
|
233
|
+
"sortText": "00_update_returning"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"label": "DELETE",
|
|
237
|
+
"kind": 14,
|
|
238
|
+
"detail": "Delete statement",
|
|
239
|
+
"documentation": {
|
|
240
|
+
"value": "Remove rows from a table.\n\n```sql\nDELETE FROM users WHERE active = false;\n```"
|
|
241
|
+
},
|
|
242
|
+
"insertText": "DELETE FROM ${1:table}\nWHERE ${2:condition};",
|
|
243
|
+
"insertTextRules": 4,
|
|
244
|
+
"sortText": "00_delete"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"label": "DELETE JOIN",
|
|
248
|
+
"kind": 15,
|
|
249
|
+
"detail": "Delete with JOIN",
|
|
250
|
+
"documentation": {
|
|
251
|
+
"value": "Delete using a joined table.\n\n```sql\nDELETE o\nFROM orders o\nJOIN users u ON o.user_id = u.id\nWHERE u.active = false;\n```"
|
|
252
|
+
},
|
|
253
|
+
"insertText": "DELETE ${1:a}\nFROM ${2:table1} ${1:a}\nJOIN ${3:table2} ${4:b} ON ${1:a}.${5:fk} = ${4:b}.${6:pk}\nWHERE ${7:condition};",
|
|
254
|
+
"insertTextRules": 4,
|
|
255
|
+
"sortText": "00_delete_join"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"label": "DELETE RETURNING",
|
|
259
|
+
"kind": 15,
|
|
260
|
+
"detail": "Delete with RETURNING (PostgreSQL)",
|
|
261
|
+
"documentation": {
|
|
262
|
+
"value": "Return deleted rows.\n\n```sql\nDELETE FROM users WHERE active = false RETURNING id, name;\n```"
|
|
263
|
+
},
|
|
264
|
+
"insertText": "DELETE FROM ${1:table}\nWHERE ${2:condition}\nRETURNING ${3:*};",
|
|
265
|
+
"insertTextRules": 4,
|
|
266
|
+
"sortText": "00_delete_returning"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"label": "TRUNCATE",
|
|
270
|
+
"kind": 14,
|
|
271
|
+
"detail": "Truncate table",
|
|
272
|
+
"documentation": {
|
|
273
|
+
"value": "Remove all rows from a table (fast, non-logged).\n\n```sql\nTRUNCATE TABLE logs;\n```"
|
|
274
|
+
},
|
|
275
|
+
"insertText": "TRUNCATE TABLE ${1:table};",
|
|
276
|
+
"insertTextRules": 4,
|
|
277
|
+
"sortText": "00_truncate"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"label": "MERGE",
|
|
281
|
+
"kind": 15,
|
|
282
|
+
"detail": "Merge / upsert (SQL:2003)",
|
|
283
|
+
"documentation": {
|
|
284
|
+
"value": "ANSI MERGE statement.\n\n```sql\nMERGE INTO target t\nUSING source s ON t.id = s.id\nWHEN MATCHED THEN UPDATE SET t.name = s.name\nWHEN NOT MATCHED THEN INSERT (id, name) VALUES (s.id, s.name);\n```"
|
|
285
|
+
},
|
|
286
|
+
"insertText": "MERGE INTO ${1:target} ${2:t}\nUSING ${3:source} ${4:s} ON ${2:t}.${5:id} = ${4:s}.${5:id}\nWHEN MATCHED THEN\n UPDATE SET ${2:t}.${6:col} = ${4:s}.${6:col}\nWHEN NOT MATCHED THEN\n INSERT (${7:columns}) VALUES (${8:values});",
|
|
287
|
+
"insertTextRules": 4,
|
|
288
|
+
"sortText": "00_merge"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"label": "CREATE TABLE",
|
|
292
|
+
"kind": 15,
|
|
293
|
+
"detail": "Create table",
|
|
294
|
+
"documentation": {
|
|
295
|
+
"value": "Create a new table.\n\n```sql\nCREATE TABLE users (\n id SERIAL PRIMARY KEY,\n name VARCHAR(100) NOT NULL\n);\n```"
|
|
296
|
+
},
|
|
297
|
+
"insertText": "CREATE TABLE ${1:table_name} (\n ${2:id} ${3:SERIAL} PRIMARY KEY,\n ${4:column} ${5:VARCHAR(255)} ${6:NOT NULL}\n);",
|
|
298
|
+
"insertTextRules": 4,
|
|
299
|
+
"sortText": "00_create_table"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"label": "CREATE TABLE constraints",
|
|
303
|
+
"kind": 15,
|
|
304
|
+
"detail": "Create table with constraints",
|
|
305
|
+
"documentation": {
|
|
306
|
+
"value": "Table with multiple constraints.\n\n```sql\nCREATE TABLE orders (\n id SERIAL PRIMARY KEY,\n user_id INT NOT NULL REFERENCES users(id),\n amount NUMERIC(10,2) CHECK (amount > 0),\n status VARCHAR(20) DEFAULT 'pending'\n);\n```"
|
|
307
|
+
},
|
|
308
|
+
"insertText": "CREATE TABLE ${1:table_name} (\n ${2:id} SERIAL PRIMARY KEY,\n ${3:foreign_col} INT NOT NULL REFERENCES ${4:parent}(${5:id}),\n ${6:col} ${7:NUMERIC(10,2)} CHECK (${6:col} ${8:> 0}),\n ${9:col2} ${10:VARCHAR(50)} DEFAULT ${11:'value'}\n);",
|
|
309
|
+
"insertTextRules": 4,
|
|
310
|
+
"sortText": "00_create_table_constraints"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"label": "CREATE TABLE FK",
|
|
314
|
+
"kind": 15,
|
|
315
|
+
"detail": "Create table with foreign key",
|
|
316
|
+
"documentation": {
|
|
317
|
+
"value": "Table with explicit foreign key constraint.\n\n```sql\nCREATE TABLE order_items (\n id SERIAL PRIMARY KEY,\n order_id INT NOT NULL,\n product_id INT NOT NULL,\n CONSTRAINT fk_order FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE\n);\n```"
|
|
318
|
+
},
|
|
319
|
+
"insertText": "CREATE TABLE ${1:table_name} (\n ${2:id} SERIAL PRIMARY KEY,\n ${3:fk_col} INT NOT NULL,\n CONSTRAINT ${4:fk_name} FOREIGN KEY (${3:fk_col})\n REFERENCES ${5:parent_table}(${6:parent_col})\n ON DELETE ${7|CASCADE,SET NULL,RESTRICT,NO ACTION|}\n);",
|
|
320
|
+
"insertTextRules": 4,
|
|
321
|
+
"sortText": "00_create_table_fk"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"label": "CREATE TABLE composite PK",
|
|
325
|
+
"kind": 15,
|
|
326
|
+
"detail": "Create table with composite primary key",
|
|
327
|
+
"documentation": {
|
|
328
|
+
"value": "Table with a multi-column primary key.\n\n```sql\nCREATE TABLE enrollment (\n student_id INT,\n course_id INT,\n enrolled_at TIMESTAMP DEFAULT NOW(),\n PRIMARY KEY (student_id, course_id)\n);\n```"
|
|
329
|
+
},
|
|
330
|
+
"insertText": "CREATE TABLE ${1:table_name} (\n ${2:col1} ${3:INT},\n ${4:col2} ${5:INT},\n ${6:col3} ${7:TIMESTAMP} DEFAULT ${8:NOW()},\n PRIMARY KEY (${2:col1}, ${4:col2})\n);",
|
|
331
|
+
"insertTextRules": 4,
|
|
332
|
+
"sortText": "00_create_table_composite_pk"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"label": "CREATE TABLE IF NOT EXISTS",
|
|
336
|
+
"kind": 15,
|
|
337
|
+
"detail": "Create table if not exists",
|
|
338
|
+
"documentation": {
|
|
339
|
+
"value": "Create only if table doesn't exist.\n\n```sql\nCREATE TABLE IF NOT EXISTS logs (\n id SERIAL PRIMARY KEY,\n message TEXT,\n created_at TIMESTAMP DEFAULT NOW()\n);\n```"
|
|
340
|
+
},
|
|
341
|
+
"insertText": "CREATE TABLE IF NOT EXISTS ${1:table_name} (\n ${2:id} SERIAL PRIMARY KEY,\n ${3:column} ${4:TEXT},\n ${5:created_at} TIMESTAMP DEFAULT NOW()\n);",
|
|
342
|
+
"insertTextRules": 4,
|
|
343
|
+
"sortText": "00_create_table_if_not_exists"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"label": "CREATE TABLE AS SELECT",
|
|
347
|
+
"kind": 15,
|
|
348
|
+
"detail": "Create table as select",
|
|
349
|
+
"documentation": {
|
|
350
|
+
"value": "Create a table from a query.\n\n```sql\nCREATE TABLE active_users AS\nSELECT * FROM users WHERE active = true;\n```"
|
|
351
|
+
},
|
|
352
|
+
"insertText": "CREATE TABLE ${1:new_table} AS\nSELECT ${2:*}\nFROM ${3:source_table}\nWHERE ${4:condition};",
|
|
353
|
+
"insertTextRules": 4,
|
|
354
|
+
"sortText": "00_create_table_as_select"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"label": "CREATE TEMP TABLE",
|
|
358
|
+
"kind": 15,
|
|
359
|
+
"detail": "Create temporary table",
|
|
360
|
+
"documentation": {
|
|
361
|
+
"value": "Create a session-scoped temporary table.\n\n```sql\nCREATE TEMPORARY TABLE tmp_results (\n id INT, value TEXT\n);\n```"
|
|
362
|
+
},
|
|
363
|
+
"insertText": "CREATE TEMPORARY TABLE ${1:tmp_table} (\n ${2:id} ${3:INT},\n ${4:column} ${5:TEXT}\n);",
|
|
364
|
+
"insertTextRules": 4,
|
|
365
|
+
"sortText": "00_create_temp_table"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"label": "CREATE TABLE partitioned",
|
|
369
|
+
"kind": 15,
|
|
370
|
+
"detail": "Create partitioned table (PostgreSQL)",
|
|
371
|
+
"documentation": {
|
|
372
|
+
"value": "Create a table with range partitioning.\n\n```sql\nCREATE TABLE measurements (\n id SERIAL,\n measured_at DATE NOT NULL,\n value NUMERIC\n) PARTITION BY RANGE (measured_at);\n```"
|
|
373
|
+
},
|
|
374
|
+
"insertText": "CREATE TABLE ${1:table_name} (\n ${2:id} SERIAL,\n ${3:partition_col} ${4:DATE} NOT NULL,\n ${5:col} ${6:NUMERIC}\n) PARTITION BY ${7|RANGE,LIST,HASH|} (${3:partition_col});",
|
|
375
|
+
"insertTextRules": 4,
|
|
376
|
+
"sortText": "00_create_table_partitioned"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"label": "ALTER TABLE ADD COLUMN",
|
|
380
|
+
"kind": 15,
|
|
381
|
+
"detail": "Add column",
|
|
382
|
+
"documentation": {
|
|
383
|
+
"value": "Add a new column to a table.\n\n```sql\nALTER TABLE users ADD COLUMN phone VARCHAR(20);\n```"
|
|
384
|
+
},
|
|
385
|
+
"insertText": "ALTER TABLE ${1:table}\nADD COLUMN ${2:column_name} ${3:data_type};",
|
|
386
|
+
"insertTextRules": 4,
|
|
387
|
+
"sortText": "00_alter_table_add_column"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"label": "ALTER TABLE DROP COLUMN",
|
|
391
|
+
"kind": 15,
|
|
392
|
+
"detail": "Drop column",
|
|
393
|
+
"documentation": {
|
|
394
|
+
"value": "Remove a column.\n\n```sql\nALTER TABLE users DROP COLUMN phone;\n```"
|
|
395
|
+
},
|
|
396
|
+
"insertText": "ALTER TABLE ${1:table}\nDROP COLUMN ${2:column_name};",
|
|
397
|
+
"insertTextRules": 4,
|
|
398
|
+
"sortText": "00_alter_table_drop_column"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"label": "ALTER TABLE RENAME COLUMN",
|
|
402
|
+
"kind": 15,
|
|
403
|
+
"detail": "Rename column",
|
|
404
|
+
"documentation": {
|
|
405
|
+
"value": "Rename a column.\n\n```sql\nALTER TABLE users RENAME COLUMN name TO full_name;\n```"
|
|
406
|
+
},
|
|
407
|
+
"insertText": "ALTER TABLE ${1:table}\nRENAME COLUMN ${2:old_name} TO ${3:new_name};",
|
|
408
|
+
"insertTextRules": 4,
|
|
409
|
+
"sortText": "00_alter_table_rename_column"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"label": "ALTER TABLE ALTER TYPE",
|
|
413
|
+
"kind": 15,
|
|
414
|
+
"detail": "Alter column type",
|
|
415
|
+
"documentation": {
|
|
416
|
+
"value": "Change a column's data type.\n\n```sql\nALTER TABLE users ALTER COLUMN age TYPE BIGINT;\n```"
|
|
417
|
+
},
|
|
418
|
+
"insertText": "ALTER TABLE ${1:table}\nALTER COLUMN ${2:column} TYPE ${3:new_type};",
|
|
419
|
+
"insertTextRules": 4,
|
|
420
|
+
"sortText": "00_alter_table_alter_type"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"label": "ALTER TABLE ADD CONSTRAINT",
|
|
424
|
+
"kind": 15,
|
|
425
|
+
"detail": "Add constraint",
|
|
426
|
+
"documentation": {
|
|
427
|
+
"value": "Add a constraint to a table.\n\n```sql\nALTER TABLE orders ADD CONSTRAINT chk_amount CHECK (amount > 0);\n```"
|
|
428
|
+
},
|
|
429
|
+
"insertText": "ALTER TABLE ${1:table}\nADD CONSTRAINT ${2:constraint_name} ${3|CHECK,UNIQUE,FOREIGN KEY|} (${4:column});",
|
|
430
|
+
"insertTextRules": 4,
|
|
431
|
+
"sortText": "00_alter_table_add_constraint"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"label": "ALTER TABLE DROP CONSTRAINT",
|
|
435
|
+
"kind": 15,
|
|
436
|
+
"detail": "Drop constraint",
|
|
437
|
+
"documentation": {
|
|
438
|
+
"value": "Remove a constraint.\n\n```sql\nALTER TABLE orders DROP CONSTRAINT chk_amount;\n```"
|
|
439
|
+
},
|
|
440
|
+
"insertText": "ALTER TABLE ${1:table}\nDROP CONSTRAINT ${2:constraint_name};",
|
|
441
|
+
"insertTextRules": 4,
|
|
442
|
+
"sortText": "00_alter_table_drop_constraint"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"label": "ALTER TABLE RENAME",
|
|
446
|
+
"kind": 15,
|
|
447
|
+
"detail": "Rename table",
|
|
448
|
+
"documentation": {
|
|
449
|
+
"value": "Rename a table.\n\n```sql\nALTER TABLE old_name RENAME TO new_name;\n```"
|
|
450
|
+
},
|
|
451
|
+
"insertText": "ALTER TABLE ${1:old_name}\nRENAME TO ${2:new_name};",
|
|
452
|
+
"insertTextRules": 4,
|
|
453
|
+
"sortText": "00_alter_table_rename"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"label": "ALTER TABLE ADD INDEX",
|
|
457
|
+
"kind": 15,
|
|
458
|
+
"detail": "Add index (MySQL)",
|
|
459
|
+
"documentation": {
|
|
460
|
+
"value": "Add an index to a table.\n\n```sql\nALTER TABLE users ADD INDEX idx_email (email);\n```"
|
|
461
|
+
},
|
|
462
|
+
"insertText": "ALTER TABLE ${1:table}\nADD INDEX ${2:idx_name} (${3:column});",
|
|
463
|
+
"insertTextRules": 4,
|
|
464
|
+
"sortText": "00_alter_table_add_index"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
"label": "DROP TABLE",
|
|
468
|
+
"kind": 14,
|
|
469
|
+
"detail": "Drop table",
|
|
470
|
+
"documentation": {
|
|
471
|
+
"value": "Remove a table.\n\n```sql\nDROP TABLE users;\n```"
|
|
472
|
+
},
|
|
473
|
+
"insertText": "DROP TABLE ${1:table_name};",
|
|
474
|
+
"insertTextRules": 4,
|
|
475
|
+
"sortText": "00_drop table"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"label": "DROP TABLE IF EXISTS",
|
|
479
|
+
"kind": 15,
|
|
480
|
+
"detail": "Drop table if exists",
|
|
481
|
+
"documentation": {
|
|
482
|
+
"value": "Drop table only if it exists.\n\n```sql\nDROP TABLE IF EXISTS temp_data;\n```"
|
|
483
|
+
},
|
|
484
|
+
"insertText": "DROP TABLE IF EXISTS ${1:table_name};",
|
|
485
|
+
"insertTextRules": 4,
|
|
486
|
+
"sortText": "00_drop_table_if_exists"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"label": "DROP TABLE CASCADE",
|
|
490
|
+
"kind": 15,
|
|
491
|
+
"detail": "Drop table cascade",
|
|
492
|
+
"documentation": {
|
|
493
|
+
"value": "Drop table and all dependent objects.\n\n```sql\nDROP TABLE IF EXISTS users CASCADE;\n```"
|
|
494
|
+
},
|
|
495
|
+
"insertText": "DROP TABLE IF EXISTS ${1:table_name} CASCADE;",
|
|
496
|
+
"insertTextRules": 4,
|
|
497
|
+
"sortText": "00_drop_table_cascade"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"label": "CREATE INDEX",
|
|
501
|
+
"kind": 15,
|
|
502
|
+
"detail": "Create index",
|
|
503
|
+
"documentation": {
|
|
504
|
+
"value": "Create an index on a column.\n\n```sql\nCREATE INDEX idx_users_email ON users (email);\n```"
|
|
505
|
+
},
|
|
506
|
+
"insertText": "CREATE INDEX ${1:idx_name} ON ${2:table} (${3:column});",
|
|
507
|
+
"insertTextRules": 4,
|
|
508
|
+
"sortText": "00_create_index"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"label": "CREATE UNIQUE INDEX",
|
|
512
|
+
"kind": 15,
|
|
513
|
+
"detail": "Create unique index",
|
|
514
|
+
"documentation": {
|
|
515
|
+
"value": "Create a unique index.\n\n```sql\nCREATE UNIQUE INDEX idx_users_email ON users (email);\n```"
|
|
516
|
+
},
|
|
517
|
+
"insertText": "CREATE UNIQUE INDEX ${1:idx_name} ON ${2:table} (${3:column});",
|
|
518
|
+
"insertTextRules": 4,
|
|
519
|
+
"sortText": "00_create_unique_index"
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
"label": "CREATE INDEX partial",
|
|
523
|
+
"kind": 15,
|
|
524
|
+
"detail": "Create partial index (PostgreSQL)",
|
|
525
|
+
"documentation": {
|
|
526
|
+
"value": "Index only matching rows.\n\n```sql\nCREATE INDEX idx_active_users ON users (email) WHERE active = true;\n```"
|
|
527
|
+
},
|
|
528
|
+
"insertText": "CREATE INDEX ${1:idx_name} ON ${2:table} (${3:column})\nWHERE ${4:condition};",
|
|
529
|
+
"insertTextRules": 4,
|
|
530
|
+
"sortText": "00_create_index_partial"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"label": "CREATE INDEX expression",
|
|
534
|
+
"kind": 15,
|
|
535
|
+
"detail": "Create expression index",
|
|
536
|
+
"documentation": {
|
|
537
|
+
"value": "Index on an expression.\n\n```sql\nCREATE INDEX idx_lower_email ON users (LOWER(email));\n```"
|
|
538
|
+
},
|
|
539
|
+
"insertText": "CREATE INDEX ${1:idx_name} ON ${2:table} (${3:LOWER(column)});",
|
|
540
|
+
"insertTextRules": 4,
|
|
541
|
+
"sortText": "00_create_index_expression"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"label": "CREATE INDEX GIN",
|
|
545
|
+
"kind": 15,
|
|
546
|
+
"detail": "Create GIN index (PostgreSQL)",
|
|
547
|
+
"documentation": {
|
|
548
|
+
"value": "GIN index for full-text search or JSONB.\n\n```sql\nCREATE INDEX idx_data_gin ON documents USING GIN (data);\n```"
|
|
549
|
+
},
|
|
550
|
+
"insertText": "CREATE INDEX ${1:idx_name} ON ${2:table} USING GIN (${3:column});",
|
|
551
|
+
"insertTextRules": 4,
|
|
552
|
+
"sortText": "00_create_index_gin"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"label": "CREATE INDEX GiST",
|
|
556
|
+
"kind": 15,
|
|
557
|
+
"detail": "Create GiST index (PostgreSQL)",
|
|
558
|
+
"documentation": {
|
|
559
|
+
"value": "GiST index for geometric or range types.\n\n```sql\nCREATE INDEX idx_location ON places USING GIST (location);\n```"
|
|
560
|
+
},
|
|
561
|
+
"insertText": "CREATE INDEX ${1:idx_name} ON ${2:table} USING GIST (${3:column});",
|
|
562
|
+
"insertTextRules": 4,
|
|
563
|
+
"sortText": "00_create_index_gist"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"label": "CREATE INDEX INCLUDE",
|
|
567
|
+
"kind": 15,
|
|
568
|
+
"detail": "Create covering index (PostgreSQL 11+)",
|
|
569
|
+
"documentation": {
|
|
570
|
+
"value": "Include non-key columns in the index.\n\n```sql\nCREATE INDEX idx_orders ON orders (user_id) INCLUDE (total, status);\n```"
|
|
571
|
+
},
|
|
572
|
+
"insertText": "CREATE INDEX ${1:idx_name} ON ${2:table} (${3:key_column})\nINCLUDE (${4:included_columns});",
|
|
573
|
+
"insertTextRules": 4,
|
|
574
|
+
"sortText": "00_create_index_include"
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"label": "DROP INDEX",
|
|
578
|
+
"kind": 14,
|
|
579
|
+
"detail": "Drop index",
|
|
580
|
+
"documentation": {
|
|
581
|
+
"value": "Remove an index.\n\n```sql\nDROP INDEX idx_users_email;\n```"
|
|
582
|
+
},
|
|
583
|
+
"insertText": "DROP INDEX ${1:index_name};",
|
|
584
|
+
"insertTextRules": 4,
|
|
585
|
+
"sortText": "00_drop index"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
"label": "CREATE VIEW",
|
|
589
|
+
"kind": 15,
|
|
590
|
+
"detail": "Create view",
|
|
591
|
+
"documentation": {
|
|
592
|
+
"value": "Create a named view.\n\n```sql\nCREATE VIEW active_users AS\nSELECT id, name FROM users WHERE active = true;\n```"
|
|
593
|
+
},
|
|
594
|
+
"insertText": "CREATE VIEW ${1:view_name} AS\nSELECT ${2:columns}\nFROM ${3:table}\nWHERE ${4:condition};",
|
|
595
|
+
"insertTextRules": 4,
|
|
596
|
+
"sortText": "00_create_view"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"label": "CREATE MATERIALIZED VIEW",
|
|
600
|
+
"kind": 15,
|
|
601
|
+
"detail": "Create materialized view (PostgreSQL)",
|
|
602
|
+
"documentation": {
|
|
603
|
+
"value": "Create a materialized view.\n\n```sql\nCREATE MATERIALIZED VIEW mv_sales AS\nSELECT product_id, SUM(amount) AS total\nFROM sales GROUP BY product_id;\n```"
|
|
604
|
+
},
|
|
605
|
+
"insertText": "CREATE MATERIALIZED VIEW ${1:mv_name} AS\nSELECT ${2:columns}\nFROM ${3:table}\n${4:WHERE condition}\nGROUP BY ${5:column};",
|
|
606
|
+
"insertTextRules": 4,
|
|
607
|
+
"sortText": "00_create_materialized_view"
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
"label": "CREATE VIEW WITH CHECK OPTION",
|
|
611
|
+
"kind": 15,
|
|
612
|
+
"detail": "Create view with check option",
|
|
613
|
+
"documentation": {
|
|
614
|
+
"value": "View that validates inserts/updates.\n\n```sql\nCREATE VIEW active_users AS\nSELECT * FROM users WHERE active = true\nWITH CHECK OPTION;\n```"
|
|
615
|
+
},
|
|
616
|
+
"insertText": "CREATE VIEW ${1:view_name} AS\nSELECT ${2:*}\nFROM ${3:table}\nWHERE ${4:condition}\nWITH CHECK OPTION;",
|
|
617
|
+
"insertTextRules": 4,
|
|
618
|
+
"sortText": "00_create_view_with_check_option"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"label": "DROP VIEW",
|
|
622
|
+
"kind": 14,
|
|
623
|
+
"detail": "Drop view",
|
|
624
|
+
"documentation": {
|
|
625
|
+
"value": "Remove a view.\n\n```sql\nDROP VIEW IF EXISTS active_users;\n```"
|
|
626
|
+
},
|
|
627
|
+
"insertText": "DROP VIEW IF EXISTS ${1:view_name};",
|
|
628
|
+
"insertTextRules": 4,
|
|
629
|
+
"sortText": "00_drop view"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"label": "REFRESH MATERIALIZED VIEW",
|
|
633
|
+
"kind": 15,
|
|
634
|
+
"detail": "Refresh materialized view",
|
|
635
|
+
"documentation": {
|
|
636
|
+
"value": "Refresh data in a materialized view.\n\n```sql\nREFRESH MATERIALIZED VIEW CONCURRENTLY mv_sales;\n```"
|
|
637
|
+
},
|
|
638
|
+
"insertText": "REFRESH MATERIALIZED VIEW ${1|CONCURRENTLY ,|}${2:mv_name};",
|
|
639
|
+
"insertTextRules": 4,
|
|
640
|
+
"sortText": "00_refresh_materialized_view"
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"label": "CREATE SCHEMA",
|
|
644
|
+
"kind": 14,
|
|
645
|
+
"detail": "Create schema",
|
|
646
|
+
"documentation": {
|
|
647
|
+
"value": "Create a new schema.\n\n```sql\nCREATE SCHEMA IF NOT EXISTS app;\n```"
|
|
648
|
+
},
|
|
649
|
+
"insertText": "CREATE SCHEMA IF NOT EXISTS ${1:schema_name};",
|
|
650
|
+
"insertTextRules": 4,
|
|
651
|
+
"sortText": "00_create schema"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"label": "DROP SCHEMA",
|
|
655
|
+
"kind": 14,
|
|
656
|
+
"detail": "Drop schema",
|
|
657
|
+
"documentation": {
|
|
658
|
+
"value": "Remove a schema.\n\n```sql\nDROP SCHEMA IF EXISTS app CASCADE;\n```"
|
|
659
|
+
},
|
|
660
|
+
"insertText": "DROP SCHEMA IF EXISTS ${1:schema_name} CASCADE;",
|
|
661
|
+
"insertTextRules": 4,
|
|
662
|
+
"sortText": "00_drop schema"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"label": "CREATE SEQUENCE",
|
|
666
|
+
"kind": 15,
|
|
667
|
+
"detail": "Create sequence",
|
|
668
|
+
"documentation": {
|
|
669
|
+
"value": "Create an auto-incrementing sequence.\n\n```sql\nCREATE SEQUENCE user_id_seq START WITH 1 INCREMENT BY 1;\n```"
|
|
670
|
+
},
|
|
671
|
+
"insertText": "CREATE SEQUENCE ${1:seq_name}\n START WITH ${2:1}\n INCREMENT BY ${3:1}\n ${4:NO MINVALUE}\n ${5:NO MAXVALUE}\n CACHE ${6:1};",
|
|
672
|
+
"insertTextRules": 4,
|
|
673
|
+
"sortText": "00_create_sequence"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
"label": "ALTER SEQUENCE",
|
|
677
|
+
"kind": 14,
|
|
678
|
+
"detail": "Alter sequence",
|
|
679
|
+
"documentation": {
|
|
680
|
+
"value": "Modify a sequence.\n\n```sql\nALTER SEQUENCE user_id_seq RESTART WITH 1000;\n```"
|
|
681
|
+
},
|
|
682
|
+
"insertText": "ALTER SEQUENCE ${1:seq_name} RESTART WITH ${2:1000};",
|
|
683
|
+
"insertTextRules": 4,
|
|
684
|
+
"sortText": "00_alter sequence"
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
"label": "COMMENT ON",
|
|
688
|
+
"kind": 15,
|
|
689
|
+
"detail": "Comment on object",
|
|
690
|
+
"documentation": {
|
|
691
|
+
"value": "Add a comment to a database object.\n\n```sql\nCOMMENT ON TABLE users IS 'Application users table';\n```"
|
|
692
|
+
},
|
|
693
|
+
"insertText": "COMMENT ON ${1|TABLE,COLUMN,INDEX,VIEW,FUNCTION|} ${2:object_name} IS '${3:comment}';",
|
|
694
|
+
"insertTextRules": 4,
|
|
695
|
+
"sortText": "00_comment_on"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"label": "INNER JOIN",
|
|
699
|
+
"kind": 15,
|
|
700
|
+
"detail": "Inner join",
|
|
701
|
+
"documentation": {
|
|
702
|
+
"value": "Return rows that match in both tables.\n\n```sql\nSELECT * FROM orders o\nINNER JOIN users u ON o.user_id = u.id;\n```"
|
|
703
|
+
},
|
|
704
|
+
"insertText": "INNER JOIN ${1:table} ${2:alias} ON ${3:condition}",
|
|
705
|
+
"insertTextRules": 4,
|
|
706
|
+
"sortText": "00_inner_join"
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
"label": "LEFT JOIN",
|
|
710
|
+
"kind": 15,
|
|
711
|
+
"detail": "Left outer join",
|
|
712
|
+
"documentation": {
|
|
713
|
+
"value": "Return all rows from the left table plus matches.\n\n```sql\nSELECT u.name, o.total\nFROM users u\nLEFT JOIN orders o ON u.id = o.user_id;\n```"
|
|
714
|
+
},
|
|
715
|
+
"insertText": "LEFT JOIN ${1:table} ${2:alias} ON ${3:condition}",
|
|
716
|
+
"insertTextRules": 4,
|
|
717
|
+
"sortText": "00_left_join"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"label": "RIGHT JOIN",
|
|
721
|
+
"kind": 15,
|
|
722
|
+
"detail": "Right outer join",
|
|
723
|
+
"documentation": {
|
|
724
|
+
"value": "Return all rows from the right table plus matches.\n\n```sql\nSELECT u.name, o.total\nFROM orders o\nRIGHT JOIN users u ON o.user_id = u.id;\n```"
|
|
725
|
+
},
|
|
726
|
+
"insertText": "RIGHT JOIN ${1:table} ${2:alias} ON ${3:condition}",
|
|
727
|
+
"insertTextRules": 4,
|
|
728
|
+
"sortText": "00_right_join"
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
"label": "FULL OUTER JOIN",
|
|
732
|
+
"kind": 15,
|
|
733
|
+
"detail": "Full outer join",
|
|
734
|
+
"documentation": {
|
|
735
|
+
"value": "Return all rows from both tables.\n\n```sql\nSELECT a.name, b.name\nFROM table_a a\nFULL OUTER JOIN table_b b ON a.id = b.a_id;\n```"
|
|
736
|
+
},
|
|
737
|
+
"insertText": "FULL OUTER JOIN ${1:table} ${2:alias} ON ${3:condition}",
|
|
738
|
+
"insertTextRules": 4,
|
|
739
|
+
"sortText": "00_full_outer_join"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"label": "CROSS JOIN",
|
|
743
|
+
"kind": 15,
|
|
744
|
+
"detail": "Cross join",
|
|
745
|
+
"documentation": {
|
|
746
|
+
"value": "Cartesian product of two tables.\n\n```sql\nSELECT * FROM colors CROSS JOIN sizes;\n```"
|
|
747
|
+
},
|
|
748
|
+
"insertText": "CROSS JOIN ${1:table}",
|
|
749
|
+
"insertTextRules": 4,
|
|
750
|
+
"sortText": "00_cross_join"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
"label": "NATURAL JOIN",
|
|
754
|
+
"kind": 15,
|
|
755
|
+
"detail": "Natural join",
|
|
756
|
+
"documentation": {
|
|
757
|
+
"value": "Join on all columns with the same name.\n\n```sql\nSELECT * FROM employees NATURAL JOIN departments;\n```"
|
|
758
|
+
},
|
|
759
|
+
"insertText": "NATURAL JOIN ${1:table}",
|
|
760
|
+
"insertTextRules": 4,
|
|
761
|
+
"sortText": "00_natural_join"
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
"label": "Self join",
|
|
765
|
+
"kind": 15,
|
|
766
|
+
"detail": "Self join",
|
|
767
|
+
"documentation": {
|
|
768
|
+
"value": "Join a table to itself.\n\n```sql\nSELECT e.name AS employee, m.name AS manager\nFROM employees e\nJOIN employees m ON e.manager_id = m.id;\n```"
|
|
769
|
+
},
|
|
770
|
+
"insertText": "SELECT ${1:a}.${2:column} AS ${3:alias1}, ${4:b}.${5:column} AS ${6:alias2}\nFROM ${7:table} ${1:a}\nJOIN ${7:table} ${4:b} ON ${1:a}.${8:fk} = ${4:b}.${9:pk};",
|
|
771
|
+
"insertTextRules": 4,
|
|
772
|
+
"sortText": "00_self_join"
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
"label": "Multiple JOINs",
|
|
776
|
+
"kind": 15,
|
|
777
|
+
"detail": "Multiple joins",
|
|
778
|
+
"documentation": {
|
|
779
|
+
"value": "Join three or more tables.\n\n```sql\nSELECT u.name, o.id, p.name\nFROM users u\nJOIN orders o ON u.id = o.user_id\nJOIN products p ON o.product_id = p.id;\n```"
|
|
780
|
+
},
|
|
781
|
+
"insertText": "SELECT ${1:a}.${2:col}, ${3:b}.${4:col}, ${5:c}.${6:col}\nFROM ${7:table1} ${1:a}\nJOIN ${8:table2} ${3:b} ON ${1:a}.${9:id} = ${3:b}.${10:fk}\nJOIN ${11:table3} ${5:c} ON ${3:b}.${12:id} = ${5:c}.${13:fk};",
|
|
782
|
+
"insertTextRules": 4,
|
|
783
|
+
"sortText": "00_multiple_joins"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
"label": "LATERAL JOIN",
|
|
787
|
+
"kind": 15,
|
|
788
|
+
"detail": "Lateral join (PostgreSQL)",
|
|
789
|
+
"documentation": {
|
|
790
|
+
"value": "Subquery that can reference preceding FROM items.\n\n```sql\nSELECT u.name, recent.total\nFROM users u\nLEFT JOIN LATERAL (\n SELECT total FROM orders WHERE user_id = u.id ORDER BY created_at DESC LIMIT 1\n) recent ON true;\n```"
|
|
791
|
+
},
|
|
792
|
+
"insertText": "LEFT JOIN LATERAL (\n SELECT ${1:columns}\n FROM ${2:table}\n WHERE ${3:fk} = ${4:outer_alias}.${5:pk}\n ORDER BY ${6:col} DESC\n LIMIT ${7:1}\n) ${8:alias} ON true",
|
|
793
|
+
"insertTextRules": 4,
|
|
794
|
+
"sortText": "00_lateral_join"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
"label": "COUNT",
|
|
798
|
+
"kind": 1,
|
|
799
|
+
"detail": "Count rows",
|
|
800
|
+
"documentation": {
|
|
801
|
+
"value": "Count the number of rows.\n\n```sql\nSELECT COUNT(*) FROM users;\n```"
|
|
802
|
+
},
|
|
803
|
+
"insertText": "COUNT(${1:*})",
|
|
804
|
+
"insertTextRules": 4,
|
|
805
|
+
"sortText": "01_count"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
"label": "SUM",
|
|
809
|
+
"kind": 1,
|
|
810
|
+
"detail": "Sum values",
|
|
811
|
+
"documentation": {
|
|
812
|
+
"value": "Calculate the sum.\n\n```sql\nSELECT SUM(amount) FROM orders;\n```"
|
|
813
|
+
},
|
|
814
|
+
"insertText": "SUM(${1:column})",
|
|
815
|
+
"insertTextRules": 4,
|
|
816
|
+
"sortText": "01_sum"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"label": "AVG",
|
|
820
|
+
"kind": 1,
|
|
821
|
+
"detail": "Average value",
|
|
822
|
+
"documentation": {
|
|
823
|
+
"value": "Calculate the average.\n\n```sql\nSELECT AVG(salary) FROM employees;\n```"
|
|
824
|
+
},
|
|
825
|
+
"insertText": "AVG(${1:column})",
|
|
826
|
+
"insertTextRules": 4,
|
|
827
|
+
"sortText": "01_avg"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"label": "MIN",
|
|
831
|
+
"kind": 1,
|
|
832
|
+
"detail": "Minimum value",
|
|
833
|
+
"documentation": {
|
|
834
|
+
"value": "Find the minimum.\n\n```sql\nSELECT MIN(price) FROM products;\n```"
|
|
835
|
+
},
|
|
836
|
+
"insertText": "MIN(${1:column})",
|
|
837
|
+
"insertTextRules": 4,
|
|
838
|
+
"sortText": "01_min"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"label": "MAX",
|
|
842
|
+
"kind": 1,
|
|
843
|
+
"detail": "Maximum value",
|
|
844
|
+
"documentation": {
|
|
845
|
+
"value": "Find the maximum.\n\n```sql\nSELECT MAX(price) FROM products;\n```"
|
|
846
|
+
},
|
|
847
|
+
"insertText": "MAX(${1:column})",
|
|
848
|
+
"insertTextRules": 4,
|
|
849
|
+
"sortText": "01_max"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
"label": "COUNT DISTINCT",
|
|
853
|
+
"kind": 1,
|
|
854
|
+
"detail": "Count distinct values",
|
|
855
|
+
"documentation": {
|
|
856
|
+
"value": "Count unique non-null values.\n\n```sql\nSELECT COUNT(DISTINCT category) FROM products;\n```"
|
|
857
|
+
},
|
|
858
|
+
"insertText": "COUNT(DISTINCT ${1:column})",
|
|
859
|
+
"insertTextRules": 4,
|
|
860
|
+
"sortText": "01_count distinct"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
"label": "STRING_AGG",
|
|
864
|
+
"kind": 1,
|
|
865
|
+
"detail": "String aggregate (PostgreSQL)",
|
|
866
|
+
"documentation": {
|
|
867
|
+
"value": "Concatenate strings with delimiter.\n\n```sql\nSELECT STRING_AGG(name, ', ' ORDER BY name) FROM users;\n```"
|
|
868
|
+
},
|
|
869
|
+
"insertText": "STRING_AGG(${1:column}, '${2:, }' ORDER BY ${3:column})",
|
|
870
|
+
"insertTextRules": 4,
|
|
871
|
+
"sortText": "01_string_agg"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
"label": "GROUP_CONCAT",
|
|
875
|
+
"kind": 1,
|
|
876
|
+
"detail": "Group concat (MySQL)",
|
|
877
|
+
"documentation": {
|
|
878
|
+
"value": "Concatenate strings in a group.\n\n```sql\nSELECT GROUP_CONCAT(name ORDER BY name SEPARATOR ', ') FROM users;\n```"
|
|
879
|
+
},
|
|
880
|
+
"insertText": "GROUP_CONCAT(${1:column} ORDER BY ${2:column} SEPARATOR '${3:, }')",
|
|
881
|
+
"insertTextRules": 4,
|
|
882
|
+
"sortText": "01_group_concat"
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
"label": "ARRAY_AGG",
|
|
886
|
+
"kind": 1,
|
|
887
|
+
"detail": "Array aggregate (PostgreSQL)",
|
|
888
|
+
"documentation": {
|
|
889
|
+
"value": "Collect values into an array.\n\n```sql\nSELECT ARRAY_AGG(name ORDER BY name) FROM users;\n```"
|
|
890
|
+
},
|
|
891
|
+
"insertText": "ARRAY_AGG(${1:column} ORDER BY ${2:column})",
|
|
892
|
+
"insertTextRules": 4,
|
|
893
|
+
"sortText": "01_array_agg"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"label": "JSON_AGG",
|
|
897
|
+
"kind": 1,
|
|
898
|
+
"detail": "JSON aggregate (PostgreSQL)",
|
|
899
|
+
"documentation": {
|
|
900
|
+
"value": "Aggregate values as a JSON array.\n\n```sql\nSELECT JSON_AGG(row_to_json(u)) FROM users u;\n```"
|
|
901
|
+
},
|
|
902
|
+
"insertText": "JSON_AGG(${1:expression})",
|
|
903
|
+
"insertTextRules": 4,
|
|
904
|
+
"sortText": "01_json_agg"
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
"label": "BOOL_AND",
|
|
908
|
+
"kind": 1,
|
|
909
|
+
"detail": "Boolean AND aggregate (PostgreSQL)",
|
|
910
|
+
"documentation": {
|
|
911
|
+
"value": "TRUE if all values are true.\n\n```sql\nSELECT BOOL_AND(active) FROM users;\n```"
|
|
912
|
+
},
|
|
913
|
+
"insertText": "BOOL_AND(${1:column})",
|
|
914
|
+
"insertTextRules": 4,
|
|
915
|
+
"sortText": "01_bool_and"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
"label": "BOOL_OR",
|
|
919
|
+
"kind": 1,
|
|
920
|
+
"detail": "Boolean OR aggregate (PostgreSQL)",
|
|
921
|
+
"documentation": {
|
|
922
|
+
"value": "TRUE if any value is true.\n\n```sql\nSELECT BOOL_OR(active) FROM users;\n```"
|
|
923
|
+
},
|
|
924
|
+
"insertText": "BOOL_OR(${1:column})",
|
|
925
|
+
"insertTextRules": 4,
|
|
926
|
+
"sortText": "01_bool_or"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"label": "ROW_NUMBER",
|
|
930
|
+
"kind": 1,
|
|
931
|
+
"detail": "Row number",
|
|
932
|
+
"documentation": {
|
|
933
|
+
"value": "Assign sequential integers to rows.\n\n```sql\nSELECT name, ROW_NUMBER() OVER (ORDER BY salary DESC) AS rn\nFROM employees;\n```"
|
|
934
|
+
},
|
|
935
|
+
"insertText": "ROW_NUMBER() OVER (${1:PARTITION BY col} ORDER BY ${2:column})",
|
|
936
|
+
"insertTextRules": 4,
|
|
937
|
+
"sortText": "01_row_number"
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
"label": "RANK",
|
|
941
|
+
"kind": 1,
|
|
942
|
+
"detail": "Rank",
|
|
943
|
+
"documentation": {
|
|
944
|
+
"value": "Rank with gaps on ties.\n\n```sql\nSELECT name, RANK() OVER (ORDER BY score DESC) FROM students;\n```"
|
|
945
|
+
},
|
|
946
|
+
"insertText": "RANK() OVER (${1:PARTITION BY col} ORDER BY ${2:column})",
|
|
947
|
+
"insertTextRules": 4,
|
|
948
|
+
"sortText": "01_rank"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
"label": "DENSE_RANK",
|
|
952
|
+
"kind": 1,
|
|
953
|
+
"detail": "Dense rank",
|
|
954
|
+
"documentation": {
|
|
955
|
+
"value": "Rank without gaps on ties.\n\n```sql\nSELECT name, DENSE_RANK() OVER (ORDER BY score DESC) FROM students;\n```"
|
|
956
|
+
},
|
|
957
|
+
"insertText": "DENSE_RANK() OVER (${1:PARTITION BY col} ORDER BY ${2:column})",
|
|
958
|
+
"insertTextRules": 4,
|
|
959
|
+
"sortText": "01_dense_rank"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"label": "NTILE",
|
|
963
|
+
"kind": 1,
|
|
964
|
+
"detail": "N-tile",
|
|
965
|
+
"documentation": {
|
|
966
|
+
"value": "Divide rows into N buckets.\n\n```sql\nSELECT name, NTILE(4) OVER (ORDER BY salary) AS quartile\nFROM employees;\n```"
|
|
967
|
+
},
|
|
968
|
+
"insertText": "NTILE(${1:n}) OVER (ORDER BY ${2:column})",
|
|
969
|
+
"insertTextRules": 4,
|
|
970
|
+
"sortText": "01_ntile"
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
"label": "LAG",
|
|
974
|
+
"kind": 1,
|
|
975
|
+
"detail": "Lag",
|
|
976
|
+
"documentation": {
|
|
977
|
+
"value": "Access previous row value.\n\n```sql\nSELECT date, value, LAG(value) OVER (ORDER BY date) AS prev_value\nFROM metrics;\n```"
|
|
978
|
+
},
|
|
979
|
+
"insertText": "LAG(${1:column}, ${2:1}, ${3:NULL}) OVER (ORDER BY ${4:column})",
|
|
980
|
+
"insertTextRules": 4,
|
|
981
|
+
"sortText": "01_lag"
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
"label": "LEAD",
|
|
985
|
+
"kind": 1,
|
|
986
|
+
"detail": "Lead",
|
|
987
|
+
"documentation": {
|
|
988
|
+
"value": "Access next row value.\n\n```sql\nSELECT date, value, LEAD(value) OVER (ORDER BY date) AS next_value\nFROM metrics;\n```"
|
|
989
|
+
},
|
|
990
|
+
"insertText": "LEAD(${1:column}, ${2:1}, ${3:NULL}) OVER (ORDER BY ${4:column})",
|
|
991
|
+
"insertTextRules": 4,
|
|
992
|
+
"sortText": "01_lead"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"label": "FIRST_VALUE",
|
|
996
|
+
"kind": 1,
|
|
997
|
+
"detail": "First value",
|
|
998
|
+
"documentation": {
|
|
999
|
+
"value": "Get first value in the window frame.\n\n```sql\nSELECT name, FIRST_VALUE(salary) OVER (PARTITION BY dept ORDER BY salary DESC)\nFROM employees;\n```"
|
|
1000
|
+
},
|
|
1001
|
+
"insertText": "FIRST_VALUE(${1:column}) OVER (${2:PARTITION BY col} ORDER BY ${3:column})",
|
|
1002
|
+
"insertTextRules": 4,
|
|
1003
|
+
"sortText": "01_first_value"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
"label": "LAST_VALUE",
|
|
1007
|
+
"kind": 1,
|
|
1008
|
+
"detail": "Last value",
|
|
1009
|
+
"documentation": {
|
|
1010
|
+
"value": "Get last value in the window frame.\n\n```sql\nSELECT name, LAST_VALUE(salary) OVER (\n PARTITION BY dept ORDER BY salary\n ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n) FROM employees;\n```"
|
|
1011
|
+
},
|
|
1012
|
+
"insertText": "LAST_VALUE(${1:column}) OVER (${2:PARTITION BY col} ORDER BY ${3:column} ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)",
|
|
1013
|
+
"insertTextRules": 4,
|
|
1014
|
+
"sortText": "01_last_value"
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
"label": "NTH_VALUE",
|
|
1018
|
+
"kind": 1,
|
|
1019
|
+
"detail": "Nth value",
|
|
1020
|
+
"documentation": {
|
|
1021
|
+
"value": "Get Nth value in the window frame.\n\n```sql\nSELECT name, NTH_VALUE(salary, 2) OVER (PARTITION BY dept ORDER BY salary DESC)\nFROM employees;\n```"
|
|
1022
|
+
},
|
|
1023
|
+
"insertText": "NTH_VALUE(${1:column}, ${2:n}) OVER (${3:PARTITION BY col} ORDER BY ${4:column})",
|
|
1024
|
+
"insertTextRules": 4,
|
|
1025
|
+
"sortText": "01_nth_value"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
"label": "PERCENT_RANK",
|
|
1029
|
+
"kind": 1,
|
|
1030
|
+
"detail": "Percent rank",
|
|
1031
|
+
"documentation": {
|
|
1032
|
+
"value": "Relative rank as a fraction (0 to 1).\n\n```sql\nSELECT name, PERCENT_RANK() OVER (ORDER BY salary) FROM employees;\n```"
|
|
1033
|
+
},
|
|
1034
|
+
"insertText": "PERCENT_RANK() OVER (ORDER BY ${1:column})",
|
|
1035
|
+
"insertTextRules": 4,
|
|
1036
|
+
"sortText": "01_percent_rank"
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
"label": "CUME_DIST",
|
|
1040
|
+
"kind": 1,
|
|
1041
|
+
"detail": "Cumulative distribution",
|
|
1042
|
+
"documentation": {
|
|
1043
|
+
"value": "Cumulative distribution value.\n\n```sql\nSELECT name, CUME_DIST() OVER (ORDER BY salary) FROM employees;\n```"
|
|
1044
|
+
},
|
|
1045
|
+
"insertText": "CUME_DIST() OVER (ORDER BY ${1:column})",
|
|
1046
|
+
"insertTextRules": 4,
|
|
1047
|
+
"sortText": "01_cume_dist"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"label": "Window frame ROWS",
|
|
1051
|
+
"kind": 15,
|
|
1052
|
+
"detail": "Window frame clause",
|
|
1053
|
+
"documentation": {
|
|
1054
|
+
"value": "Specify a window frame.\n\n```sql\nSUM(amount) OVER (\n ORDER BY date\n ROWS BETWEEN 6 PRECEDING AND CURRENT ROW\n)\n```"
|
|
1055
|
+
},
|
|
1056
|
+
"insertText": "${1:SUM}(${2:column}) OVER (\n ${3:PARTITION BY col}\n ORDER BY ${4:column}\n ${5|ROWS,RANGE|} BETWEEN ${6|UNBOUNDED PRECEDING,n PRECEDING,CURRENT ROW|} AND ${7|CURRENT ROW,n FOLLOWING,UNBOUNDED FOLLOWING|}\n)",
|
|
1057
|
+
"insertTextRules": 4,
|
|
1058
|
+
"sortText": "00_window_frame_rows"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
"label": "CONCAT",
|
|
1062
|
+
"kind": 1,
|
|
1063
|
+
"detail": "Concatenate strings",
|
|
1064
|
+
"documentation": {
|
|
1065
|
+
"value": "Join strings together.\n\n```sql\nSELECT CONCAT(first_name, ' ', last_name) FROM users;\n```"
|
|
1066
|
+
},
|
|
1067
|
+
"insertText": "CONCAT(${1:str1}, ${2:str2})",
|
|
1068
|
+
"insertTextRules": 4,
|
|
1069
|
+
"sortText": "01_concat"
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
"label": "SUBSTRING",
|
|
1073
|
+
"kind": 1,
|
|
1074
|
+
"detail": "Substring",
|
|
1075
|
+
"documentation": {
|
|
1076
|
+
"value": "Extract part of a string.\n\n```sql\nSELECT SUBSTRING(name FROM 1 FOR 3) FROM users;\n```"
|
|
1077
|
+
},
|
|
1078
|
+
"insertText": "SUBSTRING(${1:string} FROM ${2:start} FOR ${3:length})",
|
|
1079
|
+
"insertTextRules": 4,
|
|
1080
|
+
"sortText": "01_substring"
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
"label": "LENGTH",
|
|
1084
|
+
"kind": 1,
|
|
1085
|
+
"detail": "String length",
|
|
1086
|
+
"documentation": {
|
|
1087
|
+
"value": "Get length of a string.\n\n```sql\nSELECT LENGTH(name) FROM users;\n```"
|
|
1088
|
+
},
|
|
1089
|
+
"insertText": "LENGTH(${1:string})",
|
|
1090
|
+
"insertTextRules": 4,
|
|
1091
|
+
"sortText": "01_length"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
"label": "CHAR_LENGTH",
|
|
1095
|
+
"kind": 1,
|
|
1096
|
+
"detail": "Character length",
|
|
1097
|
+
"documentation": {
|
|
1098
|
+
"value": "Get character count.\n\n```sql\nSELECT CHAR_LENGTH(name) FROM users;\n```"
|
|
1099
|
+
},
|
|
1100
|
+
"insertText": "CHAR_LENGTH(${1:string})",
|
|
1101
|
+
"insertTextRules": 4,
|
|
1102
|
+
"sortText": "01_char_length"
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
"label": "UPPER",
|
|
1106
|
+
"kind": 1,
|
|
1107
|
+
"detail": "Uppercase",
|
|
1108
|
+
"documentation": {
|
|
1109
|
+
"value": "Convert to uppercase.\n\n```sql\nSELECT UPPER(name) FROM users;\n```"
|
|
1110
|
+
},
|
|
1111
|
+
"insertText": "UPPER(${1:string})",
|
|
1112
|
+
"insertTextRules": 4,
|
|
1113
|
+
"sortText": "01_upper"
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
"label": "LOWER",
|
|
1117
|
+
"kind": 1,
|
|
1118
|
+
"detail": "Lowercase",
|
|
1119
|
+
"documentation": {
|
|
1120
|
+
"value": "Convert to lowercase.\n\n```sql\nSELECT LOWER(email) FROM users;\n```"
|
|
1121
|
+
},
|
|
1122
|
+
"insertText": "LOWER(${1:string})",
|
|
1123
|
+
"insertTextRules": 4,
|
|
1124
|
+
"sortText": "01_lower"
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
"label": "TRIM",
|
|
1128
|
+
"kind": 1,
|
|
1129
|
+
"detail": "Trim whitespace",
|
|
1130
|
+
"documentation": {
|
|
1131
|
+
"value": "Remove leading/trailing whitespace.\n\n```sql\nSELECT TRIM(name) FROM users;\n```"
|
|
1132
|
+
},
|
|
1133
|
+
"insertText": "TRIM(${1:string})",
|
|
1134
|
+
"insertTextRules": 4,
|
|
1135
|
+
"sortText": "01_trim"
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
"label": "LTRIM",
|
|
1139
|
+
"kind": 1,
|
|
1140
|
+
"detail": "Left trim",
|
|
1141
|
+
"documentation": {
|
|
1142
|
+
"value": "Remove leading whitespace.\n\n```sql\nSELECT LTRIM(name) FROM users;\n```"
|
|
1143
|
+
},
|
|
1144
|
+
"insertText": "LTRIM(${1:string})",
|
|
1145
|
+
"insertTextRules": 4,
|
|
1146
|
+
"sortText": "01_ltrim"
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
"label": "RTRIM",
|
|
1150
|
+
"kind": 1,
|
|
1151
|
+
"detail": "Right trim",
|
|
1152
|
+
"documentation": {
|
|
1153
|
+
"value": "Remove trailing whitespace.\n\n```sql\nSELECT RTRIM(name) FROM users;\n```"
|
|
1154
|
+
},
|
|
1155
|
+
"insertText": "RTRIM(${1:string})",
|
|
1156
|
+
"insertTextRules": 4,
|
|
1157
|
+
"sortText": "01_rtrim"
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
"label": "REPLACE",
|
|
1161
|
+
"kind": 1,
|
|
1162
|
+
"detail": "Replace",
|
|
1163
|
+
"documentation": {
|
|
1164
|
+
"value": "Replace occurrences of a substring.\n\n```sql\nSELECT REPLACE(url, 'http:', 'https:') FROM links;\n```"
|
|
1165
|
+
},
|
|
1166
|
+
"insertText": "REPLACE(${1:string}, ${2:'old'}, ${3:'new'})",
|
|
1167
|
+
"insertTextRules": 4,
|
|
1168
|
+
"sortText": "01_replace"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
"label": "POSITION",
|
|
1172
|
+
"kind": 1,
|
|
1173
|
+
"detail": "Position / STRPOS",
|
|
1174
|
+
"documentation": {
|
|
1175
|
+
"value": "Find substring position.\n\n```sql\nSELECT POSITION('@' IN email) FROM users;\n```"
|
|
1176
|
+
},
|
|
1177
|
+
"insertText": "POSITION(${1:'substr'} IN ${2:string})",
|
|
1178
|
+
"insertTextRules": 4,
|
|
1179
|
+
"sortText": "01_position"
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
"label": "LEFT",
|
|
1183
|
+
"kind": 1,
|
|
1184
|
+
"detail": "Left substring",
|
|
1185
|
+
"documentation": {
|
|
1186
|
+
"value": "Get leftmost characters.\n\n```sql\nSELECT LEFT(name, 5) FROM users;\n```"
|
|
1187
|
+
},
|
|
1188
|
+
"insertText": "LEFT(${1:string}, ${2:n})",
|
|
1189
|
+
"insertTextRules": 4,
|
|
1190
|
+
"sortText": "01_left"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
"label": "RIGHT",
|
|
1194
|
+
"kind": 1,
|
|
1195
|
+
"detail": "Right substring",
|
|
1196
|
+
"documentation": {
|
|
1197
|
+
"value": "Get rightmost characters.\n\n```sql\nSELECT RIGHT(phone, 4) FROM contacts;\n```"
|
|
1198
|
+
},
|
|
1199
|
+
"insertText": "RIGHT(${1:string}, ${2:n})",
|
|
1200
|
+
"insertTextRules": 4,
|
|
1201
|
+
"sortText": "01_right"
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
"label": "REVERSE",
|
|
1205
|
+
"kind": 1,
|
|
1206
|
+
"detail": "Reverse string",
|
|
1207
|
+
"documentation": {
|
|
1208
|
+
"value": "Reverse a string.\n\n```sql\nSELECT REVERSE('hello');\n```"
|
|
1209
|
+
},
|
|
1210
|
+
"insertText": "REVERSE(${1:string})",
|
|
1211
|
+
"insertTextRules": 4,
|
|
1212
|
+
"sortText": "01_reverse"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
"label": "REPEAT",
|
|
1216
|
+
"kind": 1,
|
|
1217
|
+
"detail": "Repeat string",
|
|
1218
|
+
"documentation": {
|
|
1219
|
+
"value": "Repeat a string N times.\n\n```sql\nSELECT REPEAT('-', 40);\n```"
|
|
1220
|
+
},
|
|
1221
|
+
"insertText": "REPEAT(${1:string}, ${2:n})",
|
|
1222
|
+
"insertTextRules": 4,
|
|
1223
|
+
"sortText": "01_repeat"
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
"label": "LPAD",
|
|
1227
|
+
"kind": 1,
|
|
1228
|
+
"detail": "Left pad",
|
|
1229
|
+
"documentation": {
|
|
1230
|
+
"value": "Pad string on the left.\n\n```sql\nSELECT LPAD(CAST(id AS TEXT), 5, '0') FROM orders;\n```"
|
|
1231
|
+
},
|
|
1232
|
+
"insertText": "LPAD(${1:string}, ${2:length}, ${3:'pad'})",
|
|
1233
|
+
"insertTextRules": 4,
|
|
1234
|
+
"sortText": "01_lpad"
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
"label": "RPAD",
|
|
1238
|
+
"kind": 1,
|
|
1239
|
+
"detail": "Right pad",
|
|
1240
|
+
"documentation": {
|
|
1241
|
+
"value": "Pad string on the right.\n\n```sql\nSELECT RPAD(name, 20, '.') FROM users;\n```"
|
|
1242
|
+
},
|
|
1243
|
+
"insertText": "RPAD(${1:string}, ${2:length}, ${3:'pad'})",
|
|
1244
|
+
"insertTextRules": 4,
|
|
1245
|
+
"sortText": "01_rpad"
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
"label": "SPLIT_PART",
|
|
1249
|
+
"kind": 1,
|
|
1250
|
+
"detail": "Split part (PostgreSQL)",
|
|
1251
|
+
"documentation": {
|
|
1252
|
+
"value": "Split a string and return Nth part.\n\n```sql\nSELECT SPLIT_PART(email, '@', 2) AS domain FROM users;\n```"
|
|
1253
|
+
},
|
|
1254
|
+
"insertText": "SPLIT_PART(${1:string}, '${2:delimiter}', ${3:part_number})",
|
|
1255
|
+
"insertTextRules": 4,
|
|
1256
|
+
"sortText": "01_split_part"
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
"label": "REGEXP_REPLACE",
|
|
1260
|
+
"kind": 1,
|
|
1261
|
+
"detail": "Regex replace",
|
|
1262
|
+
"documentation": {
|
|
1263
|
+
"value": "Replace using regex.\n\n```sql\nSELECT REGEXP_REPLACE(phone, '[^0-9]', '', 'g') FROM contacts;\n```"
|
|
1264
|
+
},
|
|
1265
|
+
"insertText": "REGEXP_REPLACE(${1:string}, '${2:pattern}', '${3:replacement}', '${4:flags}')",
|
|
1266
|
+
"insertTextRules": 4,
|
|
1267
|
+
"sortText": "01_regexp_replace"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
"label": "REGEXP_MATCHES",
|
|
1271
|
+
"kind": 1,
|
|
1272
|
+
"detail": "Regex matches (PostgreSQL)",
|
|
1273
|
+
"documentation": {
|
|
1274
|
+
"value": "Extract all regex matches.\n\n```sql\nSELECT REGEXP_MATCHES(text, '(\\d+)', 'g') FROM documents;\n```"
|
|
1275
|
+
},
|
|
1276
|
+
"insertText": "REGEXP_MATCHES(${1:string}, '${2:pattern}', '${3:flags}')",
|
|
1277
|
+
"insertTextRules": 4,
|
|
1278
|
+
"sortText": "01_regexp_matches"
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
"label": "TRANSLATE",
|
|
1282
|
+
"kind": 1,
|
|
1283
|
+
"detail": "Translate characters",
|
|
1284
|
+
"documentation": {
|
|
1285
|
+
"value": "Replace characters one-to-one.\n\n```sql\nSELECT TRANSLATE('abc', 'abc', 'xyz');\n```"
|
|
1286
|
+
},
|
|
1287
|
+
"insertText": "TRANSLATE(${1:string}, '${2:from}', '${3:to}')",
|
|
1288
|
+
"insertTextRules": 4,
|
|
1289
|
+
"sortText": "01_translate"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"label": "INITCAP",
|
|
1293
|
+
"kind": 1,
|
|
1294
|
+
"detail": "Initial capitals (PostgreSQL)",
|
|
1295
|
+
"documentation": {
|
|
1296
|
+
"value": "Capitalize first letter of each word.\n\n```sql\nSELECT INITCAP('hello world');\n```"
|
|
1297
|
+
},
|
|
1298
|
+
"insertText": "INITCAP(${1:string})",
|
|
1299
|
+
"insertTextRules": 4,
|
|
1300
|
+
"sortText": "01_initcap"
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
"label": "FORMAT",
|
|
1304
|
+
"kind": 1,
|
|
1305
|
+
"detail": "Format string (PostgreSQL)",
|
|
1306
|
+
"documentation": {
|
|
1307
|
+
"value": "Printf-style formatting.\n\n```sql\nSELECT FORMAT('Hello, %s! You have %s orders.', name, order_count) FROM users;\n```"
|
|
1308
|
+
},
|
|
1309
|
+
"insertText": "FORMAT('${1:template}', ${2:args})",
|
|
1310
|
+
"insertTextRules": 4,
|
|
1311
|
+
"sortText": "01_format"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
"label": "NOW",
|
|
1315
|
+
"kind": 1,
|
|
1316
|
+
"detail": "Current timestamp",
|
|
1317
|
+
"documentation": {
|
|
1318
|
+
"value": "Get current date and time.\n\n```sql\nSELECT NOW();\n```"
|
|
1319
|
+
},
|
|
1320
|
+
"insertText": "NOW()",
|
|
1321
|
+
"insertTextRules": 4,
|
|
1322
|
+
"sortText": "01_now"
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
"label": "CURRENT_TIMESTAMP",
|
|
1326
|
+
"kind": 1,
|
|
1327
|
+
"detail": "Current timestamp",
|
|
1328
|
+
"documentation": {
|
|
1329
|
+
"value": "ANSI current timestamp.\n\n```sql\nSELECT CURRENT_TIMESTAMP;\n```"
|
|
1330
|
+
},
|
|
1331
|
+
"insertText": "CURRENT_TIMESTAMP",
|
|
1332
|
+
"insertTextRules": 4,
|
|
1333
|
+
"sortText": "01_current_timestamp"
|
|
1334
|
+
},
|
|
1335
|
+
{
|
|
1336
|
+
"label": "CURRENT_DATE",
|
|
1337
|
+
"kind": 1,
|
|
1338
|
+
"detail": "Current date",
|
|
1339
|
+
"documentation": {
|
|
1340
|
+
"value": "Get current date.\n\n```sql\nSELECT CURRENT_DATE;\n```"
|
|
1341
|
+
},
|
|
1342
|
+
"insertText": "CURRENT_DATE",
|
|
1343
|
+
"insertTextRules": 4,
|
|
1344
|
+
"sortText": "01_current_date"
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
"label": "CURRENT_TIME",
|
|
1348
|
+
"kind": 1,
|
|
1349
|
+
"detail": "Current time",
|
|
1350
|
+
"documentation": {
|
|
1351
|
+
"value": "Get current time.\n\n```sql\nSELECT CURRENT_TIME;\n```"
|
|
1352
|
+
},
|
|
1353
|
+
"insertText": "CURRENT_TIME",
|
|
1354
|
+
"insertTextRules": 4,
|
|
1355
|
+
"sortText": "01_current_time"
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
"label": "DATE_TRUNC",
|
|
1359
|
+
"kind": 1,
|
|
1360
|
+
"detail": "Truncate date (PostgreSQL)",
|
|
1361
|
+
"documentation": {
|
|
1362
|
+
"value": "Truncate to specified precision.\n\n```sql\nSELECT DATE_TRUNC('month', created_at) FROM orders;\n```"
|
|
1363
|
+
},
|
|
1364
|
+
"insertText": "DATE_TRUNC('${1|year,quarter,month,week,day,hour,minute,second|}', ${2:timestamp})",
|
|
1365
|
+
"insertTextRules": 4,
|
|
1366
|
+
"sortText": "01_date_trunc"
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
"label": "EXTRACT",
|
|
1370
|
+
"kind": 1,
|
|
1371
|
+
"detail": "Extract date part",
|
|
1372
|
+
"documentation": {
|
|
1373
|
+
"value": "Extract a field from a date/timestamp.\n\n```sql\nSELECT EXTRACT(YEAR FROM created_at) FROM orders;\n```"
|
|
1374
|
+
},
|
|
1375
|
+
"insertText": "EXTRACT(${1|YEAR,MONTH,DAY,HOUR,MINUTE,SECOND,DOW,DOY,EPOCH|} FROM ${2:timestamp})",
|
|
1376
|
+
"insertTextRules": 4,
|
|
1377
|
+
"sortText": "01_extract"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
"label": "DATE_PART",
|
|
1381
|
+
"kind": 1,
|
|
1382
|
+
"detail": "Date part (PostgreSQL)",
|
|
1383
|
+
"documentation": {
|
|
1384
|
+
"value": "Get a date/time field.\n\n```sql\nSELECT DATE_PART('hour', created_at) FROM events;\n```"
|
|
1385
|
+
},
|
|
1386
|
+
"insertText": "DATE_PART('${1:field}', ${2:timestamp})",
|
|
1387
|
+
"insertTextRules": 4,
|
|
1388
|
+
"sortText": "01_date_part"
|
|
1389
|
+
},
|
|
1390
|
+
{
|
|
1391
|
+
"label": "AGE",
|
|
1392
|
+
"kind": 1,
|
|
1393
|
+
"detail": "Age between dates (PostgreSQL)",
|
|
1394
|
+
"documentation": {
|
|
1395
|
+
"value": "Calculate interval between timestamps.\n\n```sql\nSELECT AGE(NOW(), hire_date) FROM employees;\n```"
|
|
1396
|
+
},
|
|
1397
|
+
"insertText": "AGE(${1:timestamp1}, ${2:timestamp2})",
|
|
1398
|
+
"insertTextRules": 4,
|
|
1399
|
+
"sortText": "01_age"
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
"label": "DATE_ADD",
|
|
1403
|
+
"kind": 1,
|
|
1404
|
+
"detail": "Add to date (MySQL)",
|
|
1405
|
+
"documentation": {
|
|
1406
|
+
"value": "Add an interval to a date.\n\n```sql\nSELECT DATE_ADD(created_at, INTERVAL 30 DAY) FROM orders;\n```"
|
|
1407
|
+
},
|
|
1408
|
+
"insertText": "DATE_ADD(${1:date}, INTERVAL ${2:n} ${3|DAY,MONTH,YEAR,HOUR,MINUTE,SECOND|})",
|
|
1409
|
+
"insertTextRules": 4,
|
|
1410
|
+
"sortText": "01_date_add"
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
"label": "INTERVAL",
|
|
1414
|
+
"kind": 1,
|
|
1415
|
+
"detail": "Interval literal",
|
|
1416
|
+
"documentation": {
|
|
1417
|
+
"value": "Interval expression.\n\n```sql\nSELECT NOW() - INTERVAL '30 days';\n```"
|
|
1418
|
+
},
|
|
1419
|
+
"insertText": "INTERVAL '${1:30} ${2|days,hours,minutes,months,years|}'",
|
|
1420
|
+
"insertTextRules": 4,
|
|
1421
|
+
"sortText": "01_interval"
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
"label": "TO_CHAR",
|
|
1425
|
+
"kind": 1,
|
|
1426
|
+
"detail": "To char (PostgreSQL)",
|
|
1427
|
+
"documentation": {
|
|
1428
|
+
"value": "Format date/number as string.\n\n```sql\nSELECT TO_CHAR(created_at, 'YYYY-MM-DD HH24:MI') FROM events;\n```"
|
|
1429
|
+
},
|
|
1430
|
+
"insertText": "TO_CHAR(${1:timestamp}, '${2:YYYY-MM-DD}')",
|
|
1431
|
+
"insertTextRules": 4,
|
|
1432
|
+
"sortText": "01_to_char"
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
"label": "TO_DATE",
|
|
1436
|
+
"kind": 1,
|
|
1437
|
+
"detail": "To date",
|
|
1438
|
+
"documentation": {
|
|
1439
|
+
"value": "Parse string to date.\n\n```sql\nSELECT TO_DATE('2024-01-15', 'YYYY-MM-DD');\n```"
|
|
1440
|
+
},
|
|
1441
|
+
"insertText": "TO_DATE('${1:string}', '${2:YYYY-MM-DD}')",
|
|
1442
|
+
"insertTextRules": 4,
|
|
1443
|
+
"sortText": "01_to_date"
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
"label": "TO_TIMESTAMP",
|
|
1447
|
+
"kind": 1,
|
|
1448
|
+
"detail": "To timestamp",
|
|
1449
|
+
"documentation": {
|
|
1450
|
+
"value": "Parse string to timestamp.\n\n```sql\nSELECT TO_TIMESTAMP('2024-01-15 10:30:00', 'YYYY-MM-DD HH24:MI:SS');\n```"
|
|
1451
|
+
},
|
|
1452
|
+
"insertText": "TO_TIMESTAMP('${1:string}', '${2:YYYY-MM-DD HH24:MI:SS}')",
|
|
1453
|
+
"insertTextRules": 4,
|
|
1454
|
+
"sortText": "01_to_timestamp"
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
"label": "MAKE_DATE",
|
|
1458
|
+
"kind": 1,
|
|
1459
|
+
"detail": "Make date (PostgreSQL)",
|
|
1460
|
+
"documentation": {
|
|
1461
|
+
"value": "Construct a date from parts.\n\n```sql\nSELECT MAKE_DATE(2024, 1, 15);\n```"
|
|
1462
|
+
},
|
|
1463
|
+
"insertText": "MAKE_DATE(${1:year}, ${2:month}, ${3:day})",
|
|
1464
|
+
"insertTextRules": 4,
|
|
1465
|
+
"sortText": "01_make_date"
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
"label": "MAKE_INTERVAL",
|
|
1469
|
+
"kind": 1,
|
|
1470
|
+
"detail": "Make interval (PostgreSQL)",
|
|
1471
|
+
"documentation": {
|
|
1472
|
+
"value": "Construct an interval.\n\n```sql\nSELECT MAKE_INTERVAL(days => 30, hours => 12);\n```"
|
|
1473
|
+
},
|
|
1474
|
+
"insertText": "MAKE_INTERVAL(${1:days} => ${2:0})",
|
|
1475
|
+
"insertTextRules": 4,
|
|
1476
|
+
"sortText": "01_make_interval"
|
|
1477
|
+
},
|
|
1478
|
+
{
|
|
1479
|
+
"label": "DATEDIFF",
|
|
1480
|
+
"kind": 1,
|
|
1481
|
+
"detail": "Date difference (MySQL/SQL Server)",
|
|
1482
|
+
"documentation": {
|
|
1483
|
+
"value": "Calculate difference between dates.\n\n```sql\nSELECT DATEDIFF(end_date, start_date) FROM projects;\n```"
|
|
1484
|
+
},
|
|
1485
|
+
"insertText": "DATEDIFF(${1:date1}, ${2:date2})",
|
|
1486
|
+
"insertTextRules": 4,
|
|
1487
|
+
"sortText": "01_datediff"
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
"label": "ABS",
|
|
1491
|
+
"kind": 1,
|
|
1492
|
+
"detail": "Absolute value",
|
|
1493
|
+
"documentation": {
|
|
1494
|
+
"value": "Return absolute value.\n\n```sql\nSELECT ABS(-42);\n```"
|
|
1495
|
+
},
|
|
1496
|
+
"insertText": "ABS(${1:number})",
|
|
1497
|
+
"insertTextRules": 4,
|
|
1498
|
+
"sortText": "01_abs"
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
"label": "CEIL",
|
|
1502
|
+
"kind": 1,
|
|
1503
|
+
"detail": "Ceiling",
|
|
1504
|
+
"documentation": {
|
|
1505
|
+
"value": "Round up to nearest integer.\n\n```sql\nSELECT CEIL(4.2);\n```"
|
|
1506
|
+
},
|
|
1507
|
+
"insertText": "CEIL(${1:number})",
|
|
1508
|
+
"insertTextRules": 4,
|
|
1509
|
+
"sortText": "01_ceil"
|
|
1510
|
+
},
|
|
1511
|
+
{
|
|
1512
|
+
"label": "FLOOR",
|
|
1513
|
+
"kind": 1,
|
|
1514
|
+
"detail": "Floor",
|
|
1515
|
+
"documentation": {
|
|
1516
|
+
"value": "Round down to nearest integer.\n\n```sql\nSELECT FLOOR(4.9);\n```"
|
|
1517
|
+
},
|
|
1518
|
+
"insertText": "FLOOR(${1:number})",
|
|
1519
|
+
"insertTextRules": 4,
|
|
1520
|
+
"sortText": "01_floor"
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
"label": "ROUND",
|
|
1524
|
+
"kind": 1,
|
|
1525
|
+
"detail": "Round",
|
|
1526
|
+
"documentation": {
|
|
1527
|
+
"value": "Round to specified decimals.\n\n```sql\nSELECT ROUND(price, 2) FROM products;\n```"
|
|
1528
|
+
},
|
|
1529
|
+
"insertText": "ROUND(${1:number}, ${2:decimals})",
|
|
1530
|
+
"insertTextRules": 4,
|
|
1531
|
+
"sortText": "01_round"
|
|
1532
|
+
},
|
|
1533
|
+
{
|
|
1534
|
+
"label": "TRUNC",
|
|
1535
|
+
"kind": 1,
|
|
1536
|
+
"detail": "Truncate number",
|
|
1537
|
+
"documentation": {
|
|
1538
|
+
"value": "Truncate to specified decimals.\n\n```sql\nSELECT TRUNC(3.14159, 2);\n```"
|
|
1539
|
+
},
|
|
1540
|
+
"insertText": "TRUNC(${1:number}, ${2:decimals})",
|
|
1541
|
+
"insertTextRules": 4,
|
|
1542
|
+
"sortText": "01_trunc"
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
"label": "MOD",
|
|
1546
|
+
"kind": 1,
|
|
1547
|
+
"detail": "Modulo",
|
|
1548
|
+
"documentation": {
|
|
1549
|
+
"value": "Remainder of division.\n\n```sql\nSELECT MOD(10, 3);\n```"
|
|
1550
|
+
},
|
|
1551
|
+
"insertText": "MOD(${1:dividend}, ${2:divisor})",
|
|
1552
|
+
"insertTextRules": 4,
|
|
1553
|
+
"sortText": "01_mod"
|
|
1554
|
+
},
|
|
1555
|
+
{
|
|
1556
|
+
"label": "POWER",
|
|
1557
|
+
"kind": 1,
|
|
1558
|
+
"detail": "Power",
|
|
1559
|
+
"documentation": {
|
|
1560
|
+
"value": "Raise to a power.\n\n```sql\nSELECT POWER(2, 10);\n```"
|
|
1561
|
+
},
|
|
1562
|
+
"insertText": "POWER(${1:base}, ${2:exponent})",
|
|
1563
|
+
"insertTextRules": 4,
|
|
1564
|
+
"sortText": "01_power"
|
|
1565
|
+
},
|
|
1566
|
+
{
|
|
1567
|
+
"label": "SQRT",
|
|
1568
|
+
"kind": 1,
|
|
1569
|
+
"detail": "Square root",
|
|
1570
|
+
"documentation": {
|
|
1571
|
+
"value": "Calculate square root.\n\n```sql\nSELECT SQRT(144);\n```"
|
|
1572
|
+
},
|
|
1573
|
+
"insertText": "SQRT(${1:number})",
|
|
1574
|
+
"insertTextRules": 4,
|
|
1575
|
+
"sortText": "01_sqrt"
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
"label": "LOG",
|
|
1579
|
+
"kind": 1,
|
|
1580
|
+
"detail": "Logarithm",
|
|
1581
|
+
"documentation": {
|
|
1582
|
+
"value": "Calculate logarithm.\n\n```sql\nSELECT LOG(10, 1000);\n```"
|
|
1583
|
+
},
|
|
1584
|
+
"insertText": "LOG(${1:base}, ${2:number})",
|
|
1585
|
+
"insertTextRules": 4,
|
|
1586
|
+
"sortText": "01_log"
|
|
1587
|
+
},
|
|
1588
|
+
{
|
|
1589
|
+
"label": "LN",
|
|
1590
|
+
"kind": 1,
|
|
1591
|
+
"detail": "Natural logarithm",
|
|
1592
|
+
"documentation": {
|
|
1593
|
+
"value": "Natural log (base e).\n\n```sql\nSELECT LN(2.718);\n```"
|
|
1594
|
+
},
|
|
1595
|
+
"insertText": "LN(${1:number})",
|
|
1596
|
+
"insertTextRules": 4,
|
|
1597
|
+
"sortText": "01_ln"
|
|
1598
|
+
},
|
|
1599
|
+
{
|
|
1600
|
+
"label": "EXP",
|
|
1601
|
+
"kind": 1,
|
|
1602
|
+
"detail": "Exponential",
|
|
1603
|
+
"documentation": {
|
|
1604
|
+
"value": "Raise e to a power.\n\n```sql\nSELECT EXP(1);\n```"
|
|
1605
|
+
},
|
|
1606
|
+
"insertText": "EXP(${1:number})",
|
|
1607
|
+
"insertTextRules": 4,
|
|
1608
|
+
"sortText": "01_exp"
|
|
1609
|
+
},
|
|
1610
|
+
{
|
|
1611
|
+
"label": "SIGN",
|
|
1612
|
+
"kind": 1,
|
|
1613
|
+
"detail": "Sign",
|
|
1614
|
+
"documentation": {
|
|
1615
|
+
"value": "Return sign of number (-1, 0, 1).\n\n```sql\nSELECT SIGN(-42);\n```"
|
|
1616
|
+
},
|
|
1617
|
+
"insertText": "SIGN(${1:number})",
|
|
1618
|
+
"insertTextRules": 4,
|
|
1619
|
+
"sortText": "01_sign"
|
|
1620
|
+
},
|
|
1621
|
+
{
|
|
1622
|
+
"label": "GREATEST",
|
|
1623
|
+
"kind": 1,
|
|
1624
|
+
"detail": "Greatest value",
|
|
1625
|
+
"documentation": {
|
|
1626
|
+
"value": "Return the largest value.\n\n```sql\nSELECT GREATEST(a, b, c) FROM t;\n```"
|
|
1627
|
+
},
|
|
1628
|
+
"insertText": "GREATEST(${1:value1}, ${2:value2})",
|
|
1629
|
+
"insertTextRules": 4,
|
|
1630
|
+
"sortText": "01_greatest"
|
|
1631
|
+
},
|
|
1632
|
+
{
|
|
1633
|
+
"label": "LEAST",
|
|
1634
|
+
"kind": 1,
|
|
1635
|
+
"detail": "Least value",
|
|
1636
|
+
"documentation": {
|
|
1637
|
+
"value": "Return the smallest value.\n\n```sql\nSELECT LEAST(a, b, c) FROM t;\n```"
|
|
1638
|
+
},
|
|
1639
|
+
"insertText": "LEAST(${1:value1}, ${2:value2})",
|
|
1640
|
+
"insertTextRules": 4,
|
|
1641
|
+
"sortText": "01_least"
|
|
1642
|
+
},
|
|
1643
|
+
{
|
|
1644
|
+
"label": "RANDOM",
|
|
1645
|
+
"kind": 1,
|
|
1646
|
+
"detail": "Random value (PostgreSQL)",
|
|
1647
|
+
"documentation": {
|
|
1648
|
+
"value": "Generate random float between 0 and 1.\n\n```sql\nSELECT RANDOM();\n```"
|
|
1649
|
+
},
|
|
1650
|
+
"insertText": "RANDOM()",
|
|
1651
|
+
"insertTextRules": 4,
|
|
1652
|
+
"sortText": "01_random"
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
"label": "CASE WHEN",
|
|
1656
|
+
"kind": 15,
|
|
1657
|
+
"detail": "Case expression",
|
|
1658
|
+
"documentation": {
|
|
1659
|
+
"value": "Conditional logic.\n\n```sql\nSELECT name,\n CASE\n WHEN score >= 90 THEN 'A'\n WHEN score >= 80 THEN 'B'\n ELSE 'C'\n END AS grade\nFROM students;\n```"
|
|
1660
|
+
},
|
|
1661
|
+
"insertText": "CASE\n WHEN ${1:condition} THEN ${2:result}\n WHEN ${3:condition2} THEN ${4:result2}\n ELSE ${5:default}\nEND",
|
|
1662
|
+
"insertTextRules": 4,
|
|
1663
|
+
"sortText": "00_case_when"
|
|
1664
|
+
},
|
|
1665
|
+
{
|
|
1666
|
+
"label": "COALESCE",
|
|
1667
|
+
"kind": 1,
|
|
1668
|
+
"detail": "Coalesce",
|
|
1669
|
+
"documentation": {
|
|
1670
|
+
"value": "Return first non-null value.\n\n```sql\nSELECT COALESCE(nickname, name, 'Anonymous') FROM users;\n```"
|
|
1671
|
+
},
|
|
1672
|
+
"insertText": "COALESCE(${1:value1}, ${2:value2})",
|
|
1673
|
+
"insertTextRules": 4,
|
|
1674
|
+
"sortText": "01_coalesce"
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
"label": "NULLIF",
|
|
1678
|
+
"kind": 1,
|
|
1679
|
+
"detail": "Null if equal",
|
|
1680
|
+
"documentation": {
|
|
1681
|
+
"value": "Return NULL if both values are equal.\n\n```sql\nSELECT NULLIF(discount, 0) FROM products;\n```"
|
|
1682
|
+
},
|
|
1683
|
+
"insertText": "NULLIF(${1:value1}, ${2:value2})",
|
|
1684
|
+
"insertTextRules": 4,
|
|
1685
|
+
"sortText": "01_nullif"
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
"label": "IFNULL",
|
|
1689
|
+
"kind": 1,
|
|
1690
|
+
"detail": "If null (MySQL)",
|
|
1691
|
+
"documentation": {
|
|
1692
|
+
"value": "Return alternative if NULL.\n\n```sql\nSELECT IFNULL(phone, 'N/A') FROM contacts;\n```"
|
|
1693
|
+
},
|
|
1694
|
+
"insertText": "IFNULL(${1:expression}, ${2:alternative})",
|
|
1695
|
+
"insertTextRules": 4,
|
|
1696
|
+
"sortText": "01_ifnull"
|
|
1697
|
+
},
|
|
1698
|
+
{
|
|
1699
|
+
"label": "NVL",
|
|
1700
|
+
"kind": 1,
|
|
1701
|
+
"detail": "NVL (Oracle)",
|
|
1702
|
+
"documentation": {
|
|
1703
|
+
"value": "Return alternative if NULL.\n\n```sql\nSELECT NVL(commission, 0) FROM sales;\n```"
|
|
1704
|
+
},
|
|
1705
|
+
"insertText": "NVL(${1:expression}, ${2:alternative})",
|
|
1706
|
+
"insertTextRules": 4,
|
|
1707
|
+
"sortText": "01_nvl"
|
|
1708
|
+
},
|
|
1709
|
+
{
|
|
1710
|
+
"label": "IIF",
|
|
1711
|
+
"kind": 1,
|
|
1712
|
+
"detail": "Inline if (SQL Server)",
|
|
1713
|
+
"documentation": {
|
|
1714
|
+
"value": "Ternary conditional.\n\n```sql\nSELECT IIF(score >= 60, 'Pass', 'Fail') FROM exams;\n```"
|
|
1715
|
+
},
|
|
1716
|
+
"insertText": "IIF(${1:condition}, ${2:true_val}, ${3:false_val})",
|
|
1717
|
+
"insertTextRules": 4,
|
|
1718
|
+
"sortText": "01_iif"
|
|
1719
|
+
},
|
|
1720
|
+
{
|
|
1721
|
+
"label": "CAST",
|
|
1722
|
+
"kind": 1,
|
|
1723
|
+
"detail": "Cast type",
|
|
1724
|
+
"documentation": {
|
|
1725
|
+
"value": "Convert a value to a specified type.\n\n```sql\nSELECT CAST(price AS INTEGER) FROM products;\n```"
|
|
1726
|
+
},
|
|
1727
|
+
"insertText": "CAST(${1:expression} AS ${2|INTEGER,BIGINT,NUMERIC,VARCHAR,TEXT,DATE,TIMESTAMP,BOOLEAN|})",
|
|
1728
|
+
"insertTextRules": 4,
|
|
1729
|
+
"sortText": "01_cast"
|
|
1730
|
+
},
|
|
1731
|
+
{
|
|
1732
|
+
"label": "::type (PostgreSQL)",
|
|
1733
|
+
"kind": 15,
|
|
1734
|
+
"detail": "PostgreSQL cast operator",
|
|
1735
|
+
"documentation": {
|
|
1736
|
+
"value": "Cast using `::` syntax.\n\n```sql\nSELECT '2024-01-01'::DATE;\nSELECT price::INTEGER FROM products;\n```"
|
|
1737
|
+
},
|
|
1738
|
+
"insertText": "${1:expression}::${2|INTEGER,BIGINT,NUMERIC,VARCHAR,TEXT,DATE,TIMESTAMP,BOOLEAN,JSONB|}",
|
|
1739
|
+
"insertTextRules": 4,
|
|
1740
|
+
"sortText": "00_::type_(postgresql)"
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
"label": "CONVERT",
|
|
1744
|
+
"kind": 1,
|
|
1745
|
+
"detail": "Convert (MySQL/SQL Server)",
|
|
1746
|
+
"documentation": {
|
|
1747
|
+
"value": "Convert expression to a type.\n\n```sql\nSELECT CONVERT(price, SIGNED) FROM products;\n```"
|
|
1748
|
+
},
|
|
1749
|
+
"insertText": "CONVERT(${1:expression}, ${2:type})",
|
|
1750
|
+
"insertTextRules": 4,
|
|
1751
|
+
"sortText": "01_convert"
|
|
1752
|
+
},
|
|
1753
|
+
{
|
|
1754
|
+
"label": "JSON_EXTRACT",
|
|
1755
|
+
"kind": 1,
|
|
1756
|
+
"detail": "JSON extract (MySQL)",
|
|
1757
|
+
"documentation": {
|
|
1758
|
+
"value": "Extract value from JSON.\n\n```sql\nSELECT JSON_EXTRACT(data, '$.name') FROM documents;\n```"
|
|
1759
|
+
},
|
|
1760
|
+
"insertText": "JSON_EXTRACT(${1:json_col}, '${2:\\$.path}')",
|
|
1761
|
+
"insertTextRules": 4,
|
|
1762
|
+
"sortText": "01_json_extract"
|
|
1763
|
+
},
|
|
1764
|
+
{
|
|
1765
|
+
"label": "JSON_OBJECT",
|
|
1766
|
+
"kind": 1,
|
|
1767
|
+
"detail": "JSON object",
|
|
1768
|
+
"documentation": {
|
|
1769
|
+
"value": "Create a JSON object.\n\n```sql\nSELECT JSON_OBJECT('name', name, 'email', email) FROM users;\n```"
|
|
1770
|
+
},
|
|
1771
|
+
"insertText": "JSON_OBJECT(${1:'key'}, ${2:value})",
|
|
1772
|
+
"insertTextRules": 4,
|
|
1773
|
+
"sortText": "01_json_object"
|
|
1774
|
+
},
|
|
1775
|
+
{
|
|
1776
|
+
"label": "JSON_ARRAY",
|
|
1777
|
+
"kind": 1,
|
|
1778
|
+
"detail": "JSON array",
|
|
1779
|
+
"documentation": {
|
|
1780
|
+
"value": "Create a JSON array.\n\n```sql\nSELECT JSON_ARRAY(1, 2, 3);\n```"
|
|
1781
|
+
},
|
|
1782
|
+
"insertText": "JSON_ARRAY(${1:values})",
|
|
1783
|
+
"insertTextRules": 4,
|
|
1784
|
+
"sortText": "01_json_array"
|
|
1785
|
+
},
|
|
1786
|
+
{
|
|
1787
|
+
"label": "JSON_SET",
|
|
1788
|
+
"kind": 1,
|
|
1789
|
+
"detail": "JSON set (MySQL)",
|
|
1790
|
+
"documentation": {
|
|
1791
|
+
"value": "Set value in JSON.\n\n```sql\nSELECT JSON_SET(data, '$.status', 'active') FROM documents;\n```"
|
|
1792
|
+
},
|
|
1793
|
+
"insertText": "JSON_SET(${1:json_col}, '${2:\\$.path}', ${3:value})",
|
|
1794
|
+
"insertTextRules": 4,
|
|
1795
|
+
"sortText": "01_json_set"
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
"label": "JSON_REMOVE",
|
|
1799
|
+
"kind": 1,
|
|
1800
|
+
"detail": "JSON remove (MySQL)",
|
|
1801
|
+
"documentation": {
|
|
1802
|
+
"value": "Remove key from JSON.\n\n```sql\nSELECT JSON_REMOVE(data, '$.temp') FROM documents;\n```"
|
|
1803
|
+
},
|
|
1804
|
+
"insertText": "JSON_REMOVE(${1:json_col}, '${2:\\$.path}')",
|
|
1805
|
+
"insertTextRules": 4,
|
|
1806
|
+
"sortText": "01_json_remove"
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
"label": "jsonb -> operator",
|
|
1810
|
+
"kind": 15,
|
|
1811
|
+
"detail": "JSONB get object (PostgreSQL)",
|
|
1812
|
+
"documentation": {
|
|
1813
|
+
"value": "Get JSON object field by key.\n\n```sql\nSELECT data -> 'name' FROM documents;\nSELECT data ->> 'name' FROM documents; -- as text\n```"
|
|
1814
|
+
},
|
|
1815
|
+
"insertText": "${1:column} ->> '${2:key}'",
|
|
1816
|
+
"insertTextRules": 4,
|
|
1817
|
+
"sortText": "00_jsonb_->_operator"
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
"label": "jsonb #> operator",
|
|
1821
|
+
"kind": 15,
|
|
1822
|
+
"detail": "JSONB path extract (PostgreSQL)",
|
|
1823
|
+
"documentation": {
|
|
1824
|
+
"value": "Get JSON value at path.\n\n```sql\nSELECT data #> '{address,city}' FROM users;\nSELECT data #>> '{address,city}' FROM users; -- as text\n```"
|
|
1825
|
+
},
|
|
1826
|
+
"insertText": "${1:column} #>> '{${2:path}}'",
|
|
1827
|
+
"insertTextRules": 4,
|
|
1828
|
+
"sortText": "00_jsonb_#>_operator"
|
|
1829
|
+
},
|
|
1830
|
+
{
|
|
1831
|
+
"label": "jsonb @> operator",
|
|
1832
|
+
"kind": 15,
|
|
1833
|
+
"detail": "JSONB containment (PostgreSQL)",
|
|
1834
|
+
"documentation": {
|
|
1835
|
+
"value": "Check if JSONB contains another.\n\n```sql\nSELECT * FROM documents WHERE data @> '{\"status\": \"active\"}';\n```"
|
|
1836
|
+
},
|
|
1837
|
+
"insertText": "${1:column} @> '${2:{\"key\": \"value\"}}'",
|
|
1838
|
+
"insertTextRules": 4,
|
|
1839
|
+
"sortText": "00_jsonb_@>_operator"
|
|
1840
|
+
},
|
|
1841
|
+
{
|
|
1842
|
+
"label": "jsonb ? operator",
|
|
1843
|
+
"kind": 15,
|
|
1844
|
+
"detail": "JSONB key exists (PostgreSQL)",
|
|
1845
|
+
"documentation": {
|
|
1846
|
+
"value": "Check if key exists in JSONB.\n\n```sql\nSELECT * FROM documents WHERE data ? 'email';\n```"
|
|
1847
|
+
},
|
|
1848
|
+
"insertText": "${1:column} ? '${2:key}'",
|
|
1849
|
+
"insertTextRules": 4,
|
|
1850
|
+
"sortText": "00_jsonb_?_operator"
|
|
1851
|
+
},
|
|
1852
|
+
{
|
|
1853
|
+
"label": "JSON_BUILD_OBJECT",
|
|
1854
|
+
"kind": 1,
|
|
1855
|
+
"detail": "Build JSON object (PostgreSQL)",
|
|
1856
|
+
"documentation": {
|
|
1857
|
+
"value": "Build a JSON object from pairs.\n\n```sql\nSELECT JSON_BUILD_OBJECT('id', id, 'name', name) FROM users;\n```"
|
|
1858
|
+
},
|
|
1859
|
+
"insertText": "JSON_BUILD_OBJECT(${1:'key'}, ${2:value})",
|
|
1860
|
+
"insertTextRules": 4,
|
|
1861
|
+
"sortText": "01_json_build_object"
|
|
1862
|
+
},
|
|
1863
|
+
{
|
|
1864
|
+
"label": "JSON_EACH",
|
|
1865
|
+
"kind": 1,
|
|
1866
|
+
"detail": "JSON each (PostgreSQL)",
|
|
1867
|
+
"documentation": {
|
|
1868
|
+
"value": "Expand JSON to set of key-value pairs.\n\n```sql\nSELECT * FROM JSON_EACH('{\"a\":1,\"b\":2}');\n```"
|
|
1869
|
+
},
|
|
1870
|
+
"insertText": "JSON_EACH(${1:json_expression})",
|
|
1871
|
+
"insertTextRules": 4,
|
|
1872
|
+
"sortText": "01_json_each"
|
|
1873
|
+
},
|
|
1874
|
+
{
|
|
1875
|
+
"label": "JSON_TYPEOF",
|
|
1876
|
+
"kind": 1,
|
|
1877
|
+
"detail": "JSON typeof (PostgreSQL)",
|
|
1878
|
+
"documentation": {
|
|
1879
|
+
"value": "Get the type of a JSON value.\n\n```sql\nSELECT JSON_TYPEOF(data -> 'count') FROM documents;\n```"
|
|
1880
|
+
},
|
|
1881
|
+
"insertText": "JSON_TYPEOF(${1:json_expression})",
|
|
1882
|
+
"insertTextRules": 4,
|
|
1883
|
+
"sortText": "01_json_typeof"
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
"label": "JSON_ARRAY_LENGTH",
|
|
1887
|
+
"kind": 1,
|
|
1888
|
+
"detail": "JSON array length (PostgreSQL)",
|
|
1889
|
+
"documentation": {
|
|
1890
|
+
"value": "Get length of a JSON array.\n\n```sql\nSELECT JSON_ARRAY_LENGTH(data -> 'items') FROM orders;\n```"
|
|
1891
|
+
},
|
|
1892
|
+
"insertText": "JSON_ARRAY_LENGTH(${1:json_array})",
|
|
1893
|
+
"insertTextRules": 4,
|
|
1894
|
+
"sortText": "01_json_array_length"
|
|
1895
|
+
},
|
|
1896
|
+
{
|
|
1897
|
+
"label": "WITH CTE",
|
|
1898
|
+
"kind": 15,
|
|
1899
|
+
"detail": "Common table expression",
|
|
1900
|
+
"documentation": {
|
|
1901
|
+
"value": "Define a named subquery.\n\n```sql\nWITH active_users AS (\n SELECT * FROM users WHERE active = true\n)\nSELECT * FROM active_users;\n```"
|
|
1902
|
+
},
|
|
1903
|
+
"insertText": "WITH ${1:cte_name} AS (\n SELECT ${2:columns}\n FROM ${3:table}\n WHERE ${4:condition}\n)\nSELECT ${5:*}\nFROM ${1:cte_name};",
|
|
1904
|
+
"insertTextRules": 4,
|
|
1905
|
+
"sortText": "00_with_cte"
|
|
1906
|
+
},
|
|
1907
|
+
{
|
|
1908
|
+
"label": "WITH RECURSIVE",
|
|
1909
|
+
"kind": 15,
|
|
1910
|
+
"detail": "Recursive CTE",
|
|
1911
|
+
"documentation": {
|
|
1912
|
+
"value": "Recursive common table expression.\n\n```sql\nWITH RECURSIVE hierarchy AS (\n SELECT id, name, parent_id, 1 AS level\n FROM categories WHERE parent_id IS NULL\n UNION ALL\n SELECT c.id, c.name, c.parent_id, h.level + 1\n FROM categories c\n JOIN hierarchy h ON c.parent_id = h.id\n)\nSELECT * FROM hierarchy;\n```"
|
|
1913
|
+
},
|
|
1914
|
+
"insertText": "WITH RECURSIVE ${1:cte_name} AS (\n -- Base case\n SELECT ${2:id}, ${3:columns}, 1 AS ${4:level}\n FROM ${5:table}\n WHERE ${6:parent_id IS NULL}\n UNION ALL\n -- Recursive case\n SELECT ${7:t}.${2:id}, ${7:t}.${3:columns}, ${8:r}.${4:level} + 1\n FROM ${5:table} ${7:t}\n JOIN ${1:cte_name} ${8:r} ON ${7:t}.${9:parent_id} = ${8:r}.${2:id}\n)\nSELECT * FROM ${1:cte_name};",
|
|
1915
|
+
"insertTextRules": 4,
|
|
1916
|
+
"sortText": "00_with_recursive"
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
"label": "Multiple CTEs",
|
|
1920
|
+
"kind": 15,
|
|
1921
|
+
"detail": "Multiple CTEs",
|
|
1922
|
+
"documentation": {
|
|
1923
|
+
"value": "Chain several CTEs.\n\n```sql\nWITH\n users_cte AS (SELECT * FROM users WHERE active),\n orders_cte AS (SELECT * FROM orders WHERE total > 100)\nSELECT u.name, o.total\nFROM users_cte u JOIN orders_cte o ON u.id = o.user_id;\n```"
|
|
1924
|
+
},
|
|
1925
|
+
"insertText": "WITH\n ${1:cte1} AS (\n SELECT ${2:*} FROM ${3:table1} WHERE ${4:condition1}\n ),\n ${5:cte2} AS (\n SELECT ${6:*} FROM ${7:table2} WHERE ${8:condition2}\n )\nSELECT ${9:columns}\nFROM ${1:cte1}\nJOIN ${5:cte2} ON ${10:join_condition};",
|
|
1926
|
+
"insertTextRules": 4,
|
|
1927
|
+
"sortText": "00_multiple_ctes"
|
|
1928
|
+
},
|
|
1929
|
+
{
|
|
1930
|
+
"label": "UNION",
|
|
1931
|
+
"kind": 14,
|
|
1932
|
+
"detail": "Union",
|
|
1933
|
+
"documentation": {
|
|
1934
|
+
"value": "Combine results removing duplicates.\n\n```sql\nSELECT name FROM customers\nUNION\nSELECT name FROM suppliers;\n```"
|
|
1935
|
+
},
|
|
1936
|
+
"insertText": "SELECT ${1:columns} FROM ${2:table1}\nUNION\nSELECT ${1:columns} FROM ${3:table2};",
|
|
1937
|
+
"insertTextRules": 4,
|
|
1938
|
+
"sortText": "00_union"
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
"label": "UNION ALL",
|
|
1942
|
+
"kind": 14,
|
|
1943
|
+
"detail": "Union all",
|
|
1944
|
+
"documentation": {
|
|
1945
|
+
"value": "Combine results keeping duplicates.\n\n```sql\nSELECT name FROM customers\nUNION ALL\nSELECT name FROM suppliers;\n```"
|
|
1946
|
+
},
|
|
1947
|
+
"insertText": "SELECT ${1:columns} FROM ${2:table1}\nUNION ALL\nSELECT ${1:columns} FROM ${3:table2};",
|
|
1948
|
+
"insertTextRules": 4,
|
|
1949
|
+
"sortText": "00_union all"
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
"label": "INTERSECT",
|
|
1953
|
+
"kind": 14,
|
|
1954
|
+
"detail": "Intersect",
|
|
1955
|
+
"documentation": {
|
|
1956
|
+
"value": "Return rows present in both queries.\n\n```sql\nSELECT id FROM table_a\nINTERSECT\nSELECT id FROM table_b;\n```"
|
|
1957
|
+
},
|
|
1958
|
+
"insertText": "SELECT ${1:columns} FROM ${2:table1}\nINTERSECT\nSELECT ${1:columns} FROM ${3:table2};",
|
|
1959
|
+
"insertTextRules": 4,
|
|
1960
|
+
"sortText": "00_intersect"
|
|
1961
|
+
},
|
|
1962
|
+
{
|
|
1963
|
+
"label": "EXCEPT",
|
|
1964
|
+
"kind": 14,
|
|
1965
|
+
"detail": "Except",
|
|
1966
|
+
"documentation": {
|
|
1967
|
+
"value": "Return rows in first query but not second.\n\n```sql\nSELECT id FROM all_users\nEXCEPT\nSELECT id FROM banned_users;\n```"
|
|
1968
|
+
},
|
|
1969
|
+
"insertText": "SELECT ${1:columns} FROM ${2:table1}\nEXCEPT\nSELECT ${1:columns} FROM ${3:table2};",
|
|
1970
|
+
"insertTextRules": 4,
|
|
1971
|
+
"sortText": "00_except"
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
"label": "BEGIN",
|
|
1975
|
+
"kind": 14,
|
|
1976
|
+
"detail": "Begin transaction",
|
|
1977
|
+
"documentation": {
|
|
1978
|
+
"value": "Start a transaction.\n\n```sql\nBEGIN;\n```"
|
|
1979
|
+
},
|
|
1980
|
+
"insertText": "BEGIN;",
|
|
1981
|
+
"insertTextRules": 4,
|
|
1982
|
+
"sortText": "00_begin"
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
"label": "COMMIT",
|
|
1986
|
+
"kind": 14,
|
|
1987
|
+
"detail": "Commit transaction",
|
|
1988
|
+
"documentation": {
|
|
1989
|
+
"value": "Save all changes made in the transaction.\n\n```sql\nCOMMIT;\n```"
|
|
1990
|
+
},
|
|
1991
|
+
"insertText": "COMMIT;",
|
|
1992
|
+
"insertTextRules": 4,
|
|
1993
|
+
"sortText": "00_commit"
|
|
1994
|
+
},
|
|
1995
|
+
{
|
|
1996
|
+
"label": "ROLLBACK",
|
|
1997
|
+
"kind": 14,
|
|
1998
|
+
"detail": "Rollback transaction",
|
|
1999
|
+
"documentation": {
|
|
2000
|
+
"value": "Undo all changes made in the transaction.\n\n```sql\nROLLBACK;\n```"
|
|
2001
|
+
},
|
|
2002
|
+
"insertText": "ROLLBACK;",
|
|
19
2003
|
"insertTextRules": 4,
|
|
20
|
-
"sortText": "
|
|
2004
|
+
"sortText": "00_rollback"
|
|
21
2005
|
},
|
|
22
2006
|
{
|
|
23
|
-
"label": "
|
|
24
|
-
"kind":
|
|
25
|
-
"detail": "
|
|
26
|
-
"documentation": {
|
|
27
|
-
|
|
2007
|
+
"label": "SAVEPOINT",
|
|
2008
|
+
"kind": 14,
|
|
2009
|
+
"detail": "Savepoint",
|
|
2010
|
+
"documentation": {
|
|
2011
|
+
"value": "Create a savepoint within a transaction.\n\n```sql\nSAVEPOINT my_savepoint;\n```"
|
|
2012
|
+
},
|
|
2013
|
+
"insertText": "SAVEPOINT ${1:name};",
|
|
28
2014
|
"insertTextRules": 4,
|
|
29
|
-
"sortText": "
|
|
2015
|
+
"sortText": "00_savepoint"
|
|
30
2016
|
},
|
|
31
2017
|
{
|
|
32
|
-
"label": "
|
|
2018
|
+
"label": "RELEASE SAVEPOINT",
|
|
33
2019
|
"kind": 14,
|
|
34
|
-
"detail": "
|
|
35
|
-
"documentation": {
|
|
36
|
-
|
|
2020
|
+
"detail": "Release savepoint",
|
|
2021
|
+
"documentation": {
|
|
2022
|
+
"value": "Release a savepoint.\n\n```sql\nRELEASE SAVEPOINT my_savepoint;\n```"
|
|
2023
|
+
},
|
|
2024
|
+
"insertText": "RELEASE SAVEPOINT ${1:name};",
|
|
37
2025
|
"insertTextRules": 4,
|
|
38
|
-
"sortText": "
|
|
2026
|
+
"sortText": "00_release savepoint"
|
|
39
2027
|
},
|
|
40
2028
|
{
|
|
41
|
-
"label": "
|
|
2029
|
+
"label": "Transaction block",
|
|
42
2030
|
"kind": 15,
|
|
43
|
-
"detail": "
|
|
44
|
-
"documentation": {
|
|
45
|
-
|
|
2031
|
+
"detail": "Full transaction block",
|
|
2032
|
+
"documentation": {
|
|
2033
|
+
"value": "Complete transaction with error handling.\n\n```sql\nBEGIN;\n UPDATE accounts SET balance = balance - 100 WHERE id = 1;\n UPDATE accounts SET balance = balance + 100 WHERE id = 2;\nCOMMIT;\n```"
|
|
2034
|
+
},
|
|
2035
|
+
"insertText": "BEGIN;\n ${1:-- statements}\n ${2:UPDATE ${3:table} SET ${4:col} = ${5:val} WHERE ${6:cond};}\nCOMMIT;",
|
|
46
2036
|
"insertTextRules": 4,
|
|
47
|
-
"sortText": "
|
|
2037
|
+
"sortText": "00_transaction_block"
|
|
48
2038
|
},
|
|
49
2039
|
{
|
|
50
|
-
"label": "
|
|
2040
|
+
"label": "GRANT",
|
|
51
2041
|
"kind": 14,
|
|
52
|
-
"detail": "
|
|
53
|
-
"documentation": {
|
|
54
|
-
|
|
2042
|
+
"detail": "Grant privileges",
|
|
2043
|
+
"documentation": {
|
|
2044
|
+
"value": "Grant permissions.\n\n```sql\nGRANT SELECT, INSERT ON users TO app_role;\n```"
|
|
2045
|
+
},
|
|
2046
|
+
"insertText": "GRANT ${1|SELECT,INSERT,UPDATE,DELETE,ALL PRIVILEGES|} ON ${2:table} TO ${3:role};",
|
|
55
2047
|
"insertTextRules": 4,
|
|
56
|
-
"sortText": "
|
|
2048
|
+
"sortText": "00_grant"
|
|
57
2049
|
},
|
|
58
2050
|
{
|
|
59
|
-
"label": "
|
|
2051
|
+
"label": "REVOKE",
|
|
60
2052
|
"kind": 14,
|
|
61
|
-
"detail": "
|
|
62
|
-
"documentation": {
|
|
63
|
-
|
|
2053
|
+
"detail": "Revoke privileges",
|
|
2054
|
+
"documentation": {
|
|
2055
|
+
"value": "Remove permissions.\n\n```sql\nREVOKE INSERT ON users FROM app_role;\n```"
|
|
2056
|
+
},
|
|
2057
|
+
"insertText": "REVOKE ${1|SELECT,INSERT,UPDATE,DELETE,ALL PRIVILEGES|} ON ${2:table} FROM ${3:role};",
|
|
64
2058
|
"insertTextRules": 4,
|
|
65
|
-
"sortText": "
|
|
2059
|
+
"sortText": "00_revoke"
|
|
66
2060
|
},
|
|
67
2061
|
{
|
|
68
|
-
"label": "
|
|
2062
|
+
"label": "EXPLAIN",
|
|
69
2063
|
"kind": 15,
|
|
70
|
-
"detail": "
|
|
71
|
-
"documentation": {
|
|
72
|
-
|
|
2064
|
+
"detail": "Explain query plan",
|
|
2065
|
+
"documentation": {
|
|
2066
|
+
"value": "Show the execution plan.\n\n```sql\nEXPLAIN SELECT * FROM users WHERE email = 'a@b.com';\n```"
|
|
2067
|
+
},
|
|
2068
|
+
"insertText": "EXPLAIN ${1:SELECT * FROM ${2:table} WHERE ${3:condition}};",
|
|
73
2069
|
"insertTextRules": 4,
|
|
74
|
-
"sortText": "
|
|
2070
|
+
"sortText": "00_explain"
|
|
75
2071
|
},
|
|
76
2072
|
{
|
|
77
|
-
"label": "
|
|
2073
|
+
"label": "EXPLAIN ANALYZE",
|
|
78
2074
|
"kind": 15,
|
|
79
|
-
"detail": "
|
|
80
|
-
"documentation": {
|
|
81
|
-
|
|
2075
|
+
"detail": "Explain analyze",
|
|
2076
|
+
"documentation": {
|
|
2077
|
+
"value": "Show execution plan with actual timings.\n\n```sql\nEXPLAIN ANALYZE SELECT * FROM users WHERE email = 'a@b.com';\n```"
|
|
2078
|
+
},
|
|
2079
|
+
"insertText": "EXPLAIN ANALYZE ${1:SELECT * FROM ${2:table} WHERE ${3:condition}};",
|
|
82
2080
|
"insertTextRules": 4,
|
|
83
|
-
"sortText": "
|
|
2081
|
+
"sortText": "00_explain_analyze"
|
|
84
2082
|
},
|
|
85
2083
|
{
|
|
86
|
-
"label": "
|
|
87
|
-
"kind":
|
|
88
|
-
"detail": "
|
|
89
|
-
"documentation": {
|
|
90
|
-
|
|
2084
|
+
"label": "VACUUM",
|
|
2085
|
+
"kind": 14,
|
|
2086
|
+
"detail": "Vacuum (PostgreSQL)",
|
|
2087
|
+
"documentation": {
|
|
2088
|
+
"value": "Reclaim storage and update statistics.\n\n```sql\nVACUUM ANALYZE users;\n```"
|
|
2089
|
+
},
|
|
2090
|
+
"insertText": "VACUUM ${1|ANALYZE,FULL,VERBOSE|} ${2:table};",
|
|
91
2091
|
"insertTextRules": 4,
|
|
92
|
-
"sortText": "
|
|
2092
|
+
"sortText": "00_vacuum"
|
|
93
2093
|
},
|
|
94
2094
|
{
|
|
95
|
-
"label": "
|
|
96
|
-
"kind":
|
|
97
|
-
"detail": "
|
|
98
|
-
"documentation": {
|
|
99
|
-
|
|
2095
|
+
"label": "CLUSTER",
|
|
2096
|
+
"kind": 14,
|
|
2097
|
+
"detail": "Cluster (PostgreSQL)",
|
|
2098
|
+
"documentation": {
|
|
2099
|
+
"value": "Reorder table rows according to an index.\n\n```sql\nCLUSTER users USING idx_users_email;\n```"
|
|
2100
|
+
},
|
|
2101
|
+
"insertText": "CLUSTER ${1:table} USING ${2:index};",
|
|
100
2102
|
"insertTextRules": 4,
|
|
101
|
-
"sortText": "
|
|
2103
|
+
"sortText": "00_cluster"
|
|
102
2104
|
},
|
|
103
2105
|
{
|
|
104
|
-
"label": "
|
|
105
|
-
"kind":
|
|
106
|
-
"detail": "
|
|
107
|
-
"documentation": {
|
|
108
|
-
|
|
2106
|
+
"label": "REINDEX",
|
|
2107
|
+
"kind": 14,
|
|
2108
|
+
"detail": "Reindex",
|
|
2109
|
+
"documentation": {
|
|
2110
|
+
"value": "Rebuild indexes.\n\n```sql\nREINDEX TABLE users;\n```"
|
|
2111
|
+
},
|
|
2112
|
+
"insertText": "REINDEX ${1|TABLE,INDEX,DATABASE|} ${2:name};",
|
|
109
2113
|
"insertTextRules": 4,
|
|
110
|
-
"sortText": "
|
|
2114
|
+
"sortText": "00_reindex"
|
|
111
2115
|
},
|
|
112
2116
|
{
|
|
113
|
-
"label": "CREATE
|
|
2117
|
+
"label": "CREATE FUNCTION",
|
|
114
2118
|
"kind": 15,
|
|
115
|
-
"detail": "Create
|
|
116
|
-
"documentation": {
|
|
117
|
-
|
|
2119
|
+
"detail": "Create function (PostgreSQL)",
|
|
2120
|
+
"documentation": {
|
|
2121
|
+
"value": "Create a PL/pgSQL function.\n\n```sql\nCREATE OR REPLACE FUNCTION get_user(p_id INT)\nRETURNS TABLE(name TEXT, email TEXT) AS $$\nBEGIN\n RETURN QUERY SELECT u.name, u.email FROM users u WHERE u.id = p_id;\nEND;\n$$ LANGUAGE plpgsql;\n```"
|
|
2122
|
+
},
|
|
2123
|
+
"insertText": "CREATE OR REPLACE FUNCTION ${1:function_name}(${2:params})\nRETURNS ${3:return_type} AS $$\nBEGIN\n ${4:-- body}\n RETURN ${5:result};\nEND;\n$$ LANGUAGE plpgsql;",
|
|
118
2124
|
"insertTextRules": 4,
|
|
119
|
-
"sortText": "
|
|
2125
|
+
"sortText": "00_create_function"
|
|
120
2126
|
},
|
|
121
2127
|
{
|
|
122
|
-
"label": "
|
|
2128
|
+
"label": "CREATE PROCEDURE",
|
|
123
2129
|
"kind": 15,
|
|
124
|
-
"detail": "
|
|
125
|
-
"documentation": {
|
|
126
|
-
|
|
2130
|
+
"detail": "Create procedure (PostgreSQL 11+ / MySQL)",
|
|
2131
|
+
"documentation": {
|
|
2132
|
+
"value": "Create a stored procedure.\n\n```sql\nCREATE OR REPLACE PROCEDURE transfer(sender INT, receiver INT, amount NUMERIC)\nLANGUAGE plpgsql AS $$\nBEGIN\n UPDATE accounts SET balance = balance - amount WHERE id = sender;\n UPDATE accounts SET balance = balance + amount WHERE id = receiver;\nEND;\n$$;\n```"
|
|
2133
|
+
},
|
|
2134
|
+
"insertText": "CREATE OR REPLACE PROCEDURE ${1:proc_name}(${2:params})\nLANGUAGE plpgsql AS $$\nBEGIN\n ${3:-- body}\nEND;\n$$;",
|
|
127
2135
|
"insertTextRules": 4,
|
|
128
|
-
"sortText": "
|
|
2136
|
+
"sortText": "00_create_procedure"
|
|
129
2137
|
},
|
|
130
2138
|
{
|
|
131
|
-
"label": "
|
|
2139
|
+
"label": "CREATE TRIGGER",
|
|
132
2140
|
"kind": 15,
|
|
133
|
-
"detail": "
|
|
134
|
-
"documentation": {
|
|
135
|
-
|
|
2141
|
+
"detail": "Create trigger",
|
|
2142
|
+
"documentation": {
|
|
2143
|
+
"value": "Create a trigger.\n\n```sql\nCREATE TRIGGER audit_update\nAFTER UPDATE ON users\nFOR EACH ROW\nEXECUTE FUNCTION log_change();\n```"
|
|
2144
|
+
},
|
|
2145
|
+
"insertText": "CREATE TRIGGER ${1:trigger_name}\n${2|BEFORE,AFTER,INSTEAD OF|} ${3|INSERT,UPDATE,DELETE|} ON ${4:table}\nFOR EACH ROW\nEXECUTE FUNCTION ${5:function_name}();",
|
|
136
2146
|
"insertTextRules": 4,
|
|
137
|
-
"sortText": "
|
|
2147
|
+
"sortText": "00_create_trigger"
|
|
138
2148
|
},
|
|
139
2149
|
{
|
|
140
|
-
"label": "
|
|
2150
|
+
"label": "CREATE TYPE",
|
|
141
2151
|
"kind": 15,
|
|
142
|
-
"detail": "
|
|
143
|
-
"documentation": {
|
|
144
|
-
|
|
2152
|
+
"detail": "Create type (PostgreSQL)",
|
|
2153
|
+
"documentation": {
|
|
2154
|
+
"value": "Create a custom composite type.\n\n```sql\nCREATE TYPE address AS (\n street TEXT,\n city TEXT,\n zip VARCHAR(10)\n);\n```"
|
|
2155
|
+
},
|
|
2156
|
+
"insertText": "CREATE TYPE ${1:type_name} AS (\n ${2:field1} ${3:TEXT},\n ${4:field2} ${5:TEXT}\n);",
|
|
145
2157
|
"insertTextRules": 4,
|
|
146
|
-
"sortText": "
|
|
2158
|
+
"sortText": "00_create_type"
|
|
147
2159
|
},
|
|
148
2160
|
{
|
|
149
|
-
"label": "
|
|
2161
|
+
"label": "CREATE ENUM",
|
|
150
2162
|
"kind": 15,
|
|
151
|
-
"detail": "
|
|
152
|
-
"documentation": {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
"
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"label": "DROP TABLE",
|
|
159
|
-
"kind": 14,
|
|
160
|
-
"detail": "Drop a table",
|
|
161
|
-
"documentation": { "value": "Permanently removes a table and all its data from the database." },
|
|
162
|
-
"insertText": "DROP TABLE IF EXISTS ${1:table_name}",
|
|
2163
|
+
"detail": "Create enum type (PostgreSQL)",
|
|
2164
|
+
"documentation": {
|
|
2165
|
+
"value": "Create an enumerated type.\n\n```sql\nCREATE TYPE status AS ENUM ('active', 'inactive', 'pending');\n```"
|
|
2166
|
+
},
|
|
2167
|
+
"insertText": "CREATE TYPE ${1:type_name} AS ENUM (${2:'value1', 'value2', 'value3'});",
|
|
163
2168
|
"insertTextRules": 4,
|
|
164
|
-
"sortText": "
|
|
2169
|
+
"sortText": "00_create_enum"
|
|
165
2170
|
},
|
|
166
2171
|
{
|
|
167
|
-
"label": "
|
|
168
|
-
"kind":
|
|
169
|
-
"detail": "
|
|
170
|
-
"documentation": {
|
|
171
|
-
|
|
2172
|
+
"label": "DO block",
|
|
2173
|
+
"kind": 15,
|
|
2174
|
+
"detail": "Anonymous code block (PostgreSQL)",
|
|
2175
|
+
"documentation": {
|
|
2176
|
+
"value": "Execute anonymous PL/pgSQL.\n\n```sql\nDO $$\nBEGIN\n RAISE NOTICE 'Hello, %', 'world';\nEND;\n$$;\n```"
|
|
2177
|
+
},
|
|
2178
|
+
"insertText": "DO $$\nBEGIN\n ${1:-- body}\nEND;\n$$;",
|
|
172
2179
|
"insertTextRules": 4,
|
|
173
|
-
"sortText": "
|
|
2180
|
+
"sortText": "00_do_block"
|
|
174
2181
|
},
|
|
175
2182
|
{
|
|
176
|
-
"label": "
|
|
177
|
-
"kind":
|
|
178
|
-
"detail": "
|
|
179
|
-
"documentation": {
|
|
180
|
-
|
|
2183
|
+
"label": "COPY",
|
|
2184
|
+
"kind": 15,
|
|
2185
|
+
"detail": "Copy (PostgreSQL)",
|
|
2186
|
+
"documentation": {
|
|
2187
|
+
"value": "Bulk load data from/to a file.\n\n```sql\nCOPY users (name, email) FROM '/tmp/users.csv' WITH (FORMAT csv, HEADER true);\n```"
|
|
2188
|
+
},
|
|
2189
|
+
"insertText": "COPY ${1:table} (${2:columns})\n${3|FROM,TO|} '${4:/path/to/file.csv}'\nWITH (FORMAT csv, HEADER true);",
|
|
181
2190
|
"insertTextRules": 4,
|
|
182
|
-
"sortText": "
|
|
2191
|
+
"sortText": "00_copy"
|
|
183
2192
|
},
|
|
184
2193
|
{
|
|
185
|
-
"label": "
|
|
186
|
-
"kind":
|
|
187
|
-
"detail": "
|
|
188
|
-
"documentation": {
|
|
189
|
-
|
|
2194
|
+
"label": "PREPARE",
|
|
2195
|
+
"kind": 15,
|
|
2196
|
+
"detail": "Prepared statement",
|
|
2197
|
+
"documentation": {
|
|
2198
|
+
"value": "Prepare a parameterized statement.\n\n```sql\nPREPARE get_user (INT) AS SELECT * FROM users WHERE id = $1;\nEXECUTE get_user(42);\n```"
|
|
2199
|
+
},
|
|
2200
|
+
"insertText": "PREPARE ${1:stmt_name} (${2:param_types}) AS\n${3:SELECT * FROM table WHERE id = \\$1};\nEXECUTE ${1:stmt_name}(${4:values});",
|
|
190
2201
|
"insertTextRules": 4,
|
|
191
|
-
"sortText": "
|
|
2202
|
+
"sortText": "00_prepare"
|
|
192
2203
|
},
|
|
193
2204
|
{
|
|
194
|
-
"label": "
|
|
2205
|
+
"label": "DEALLOCATE",
|
|
195
2206
|
"kind": 14,
|
|
196
|
-
"detail": "
|
|
197
|
-
"documentation": {
|
|
198
|
-
|
|
2207
|
+
"detail": "Deallocate prepared statement",
|
|
2208
|
+
"documentation": {
|
|
2209
|
+
"value": "Remove a prepared statement.\n\n```sql\nDEALLOCATE get_user;\n```"
|
|
2210
|
+
},
|
|
2211
|
+
"insertText": "DEALLOCATE ${1:stmt_name};",
|
|
199
2212
|
"insertTextRules": 4,
|
|
200
|
-
"sortText": "
|
|
2213
|
+
"sortText": "00_deallocate"
|
|
201
2214
|
},
|
|
202
2215
|
{
|
|
203
|
-
"label": "
|
|
2216
|
+
"label": "LOCK TABLE",
|
|
204
2217
|
"kind": 14,
|
|
205
|
-
"detail": "
|
|
206
|
-
"documentation": {
|
|
207
|
-
|
|
2218
|
+
"detail": "Lock table",
|
|
2219
|
+
"documentation": {
|
|
2220
|
+
"value": "Acquire a table lock.\n\n```sql\nLOCK TABLE accounts IN ACCESS EXCLUSIVE MODE;\n```"
|
|
2221
|
+
},
|
|
2222
|
+
"insertText": "LOCK TABLE ${1:table} IN ${2|ACCESS SHARE,ROW SHARE,ROW EXCLUSIVE,SHARE UPDATE EXCLUSIVE,SHARE,SHARE ROW EXCLUSIVE,EXCLUSIVE,ACCESS EXCLUSIVE|} MODE;",
|
|
208
2223
|
"insertTextRules": 4,
|
|
209
|
-
"sortText": "
|
|
2224
|
+
"sortText": "00_lock table"
|
|
210
2225
|
},
|
|
211
2226
|
{
|
|
212
|
-
"label": "
|
|
213
|
-
"kind":
|
|
214
|
-
"detail": "
|
|
215
|
-
"documentation": {
|
|
216
|
-
|
|
2227
|
+
"label": "Pagination query",
|
|
2228
|
+
"kind": 15,
|
|
2229
|
+
"detail": "Paginated query template",
|
|
2230
|
+
"documentation": {
|
|
2231
|
+
"value": "Offset-based pagination.\n\n```sql\nSELECT * FROM products\nORDER BY id\nLIMIT 20 OFFSET 40;\n```"
|
|
2232
|
+
},
|
|
2233
|
+
"insertText": "SELECT ${1:*}\nFROM ${2:table}\nORDER BY ${3:id}\nLIMIT ${4:20} OFFSET ${5:0};",
|
|
217
2234
|
"insertTextRules": 4,
|
|
218
|
-
"sortText": "
|
|
2235
|
+
"sortText": "00_pagination_query"
|
|
219
2236
|
},
|
|
220
2237
|
{
|
|
221
|
-
"label": "
|
|
222
|
-
"kind":
|
|
223
|
-
"detail": "
|
|
224
|
-
"documentation": {
|
|
225
|
-
|
|
2238
|
+
"label": "Keyset pagination",
|
|
2239
|
+
"kind": 15,
|
|
2240
|
+
"detail": "Keyset (cursor) pagination",
|
|
2241
|
+
"documentation": {
|
|
2242
|
+
"value": "Efficient cursor-based pagination.\n\n```sql\nSELECT * FROM products\nWHERE id > :last_id\nORDER BY id\nLIMIT 20;\n```"
|
|
2243
|
+
},
|
|
2244
|
+
"insertText": "SELECT ${1:*}\nFROM ${2:table}\nWHERE ${3:id} > ${4:last_seen_value}\nORDER BY ${3:id}\nLIMIT ${5:20};",
|
|
226
2245
|
"insertTextRules": 4,
|
|
227
|
-
"sortText": "
|
|
2246
|
+
"sortText": "00_keyset_pagination"
|
|
228
2247
|
},
|
|
229
2248
|
{
|
|
230
|
-
"label": "
|
|
231
|
-
"kind":
|
|
232
|
-
"detail": "
|
|
233
|
-
"documentation": {
|
|
234
|
-
|
|
2249
|
+
"label": "Running total",
|
|
2250
|
+
"kind": 15,
|
|
2251
|
+
"detail": "Running total window query",
|
|
2252
|
+
"documentation": {
|
|
2253
|
+
"value": "Cumulative sum using window function.\n\n```sql\nSELECT date, amount,\n SUM(amount) OVER (ORDER BY date) AS running_total\nFROM transactions;\n```"
|
|
2254
|
+
},
|
|
2255
|
+
"insertText": "SELECT ${1:date}, ${2:amount},\n SUM(${2:amount}) OVER (ORDER BY ${1:date}) AS running_total\nFROM ${3:table};",
|
|
235
2256
|
"insertTextRules": 4,
|
|
236
|
-
"sortText": "
|
|
2257
|
+
"sortText": "00_running_total"
|
|
237
2258
|
},
|
|
238
2259
|
{
|
|
239
|
-
"label": "
|
|
2260
|
+
"label": "Top-N per group",
|
|
240
2261
|
"kind": 15,
|
|
241
|
-
"detail": "
|
|
242
|
-
"documentation": {
|
|
243
|
-
|
|
2262
|
+
"detail": "Top-N per group query",
|
|
2263
|
+
"documentation": {
|
|
2264
|
+
"value": "Get top N rows per category.\n\n```sql\nSELECT * FROM (\n SELECT *, ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) AS rn\n FROM employees\n) ranked\nWHERE rn <= 3;\n```"
|
|
2265
|
+
},
|
|
2266
|
+
"insertText": "SELECT * FROM (\n SELECT *, ROW_NUMBER() OVER (PARTITION BY ${1:group_col} ORDER BY ${2:order_col} DESC) AS rn\n FROM ${3:table}\n) ranked\nWHERE rn <= ${4:3};",
|
|
244
2267
|
"insertTextRules": 4,
|
|
245
|
-
"sortText": "
|
|
2268
|
+
"sortText": "00_top-n_per_group"
|
|
246
2269
|
},
|
|
247
2270
|
{
|
|
248
|
-
"label": "
|
|
249
|
-
"kind":
|
|
250
|
-
"detail": "
|
|
251
|
-
"documentation": {
|
|
252
|
-
|
|
2271
|
+
"label": "Duplicate finder",
|
|
2272
|
+
"kind": 15,
|
|
2273
|
+
"detail": "Find duplicate rows",
|
|
2274
|
+
"documentation": {
|
|
2275
|
+
"value": "Detect duplicates.\n\n```sql\nSELECT email, COUNT(*) AS cnt\nFROM users\nGROUP BY email\nHAVING COUNT(*) > 1;\n```"
|
|
2276
|
+
},
|
|
2277
|
+
"insertText": "SELECT ${1:column}, COUNT(*) AS cnt\nFROM ${2:table}\nGROUP BY ${1:column}\nHAVING COUNT(*) > 1;",
|
|
253
2278
|
"insertTextRules": 4,
|
|
254
|
-
"sortText": "
|
|
2279
|
+
"sortText": "00_duplicate_finder"
|
|
255
2280
|
},
|
|
256
2281
|
{
|
|
257
|
-
"label": "
|
|
258
|
-
"kind":
|
|
259
|
-
"detail": "
|
|
260
|
-
"documentation": {
|
|
261
|
-
|
|
2282
|
+
"label": "Gap analysis",
|
|
2283
|
+
"kind": 15,
|
|
2284
|
+
"detail": "Find gaps in sequence",
|
|
2285
|
+
"documentation": {
|
|
2286
|
+
"value": "Detect gaps in an ID sequence.\n\n```sql\nSELECT id + 1 AS gap_start,\n LEAD(id) OVER (ORDER BY id) - 1 AS gap_end\nFROM orders\nWHERE LEAD(id) OVER (ORDER BY id) - id > 1;\n```"
|
|
2287
|
+
},
|
|
2288
|
+
"insertText": "SELECT ${1:id} + 1 AS gap_start,\n LEAD(${1:id}) OVER (ORDER BY ${1:id}) - 1 AS gap_end\nFROM ${2:table}\nWHERE LEAD(${1:id}) OVER (ORDER BY ${1:id}) - ${1:id} > 1;",
|
|
262
2289
|
"insertTextRules": 4,
|
|
263
|
-
"sortText": "
|
|
2290
|
+
"sortText": "00_gap_analysis"
|
|
264
2291
|
},
|
|
265
2292
|
{
|
|
266
|
-
"label": "
|
|
267
|
-
"kind":
|
|
268
|
-
"detail": "
|
|
269
|
-
"documentation": {
|
|
270
|
-
|
|
2293
|
+
"label": "Date series",
|
|
2294
|
+
"kind": 15,
|
|
2295
|
+
"detail": "Generate date series (PostgreSQL)",
|
|
2296
|
+
"documentation": {
|
|
2297
|
+
"value": "Generate a series of dates.\n\n```sql\nSELECT d::DATE\nFROM generate_series('2024-01-01'::DATE, '2024-12-31'::DATE, '1 day'::INTERVAL) d;\n```"
|
|
2298
|
+
},
|
|
2299
|
+
"insertText": "SELECT ${1:d}::DATE\nFROM generate_series(\n '${2:2024-01-01}'::DATE,\n '${3:2024-12-31}'::DATE,\n '${4:1 day}'::INTERVAL\n) ${1:d};",
|
|
271
2300
|
"insertTextRules": 4,
|
|
272
|
-
"sortText": "
|
|
2301
|
+
"sortText": "00_date_series"
|
|
273
2302
|
},
|
|
274
2303
|
{
|
|
275
|
-
"label": "
|
|
276
|
-
"kind":
|
|
277
|
-
"detail": "
|
|
278
|
-
"documentation": {
|
|
279
|
-
|
|
2304
|
+
"label": "Recursive tree",
|
|
2305
|
+
"kind": 15,
|
|
2306
|
+
"detail": "Recursive tree / hierarchy",
|
|
2307
|
+
"documentation": {
|
|
2308
|
+
"value": "Traverse a parent-child tree.\n\n```sql\nWITH RECURSIVE tree AS (\n SELECT id, name, parent_id, 0 AS depth, name::TEXT AS path\n FROM categories WHERE parent_id IS NULL\n UNION ALL\n SELECT c.id, c.name, c.parent_id, t.depth + 1,\n t.path || ' > ' || c.name\n FROM categories c JOIN tree t ON c.parent_id = t.id\n)\nSELECT * FROM tree ORDER BY path;\n```"
|
|
2309
|
+
},
|
|
2310
|
+
"insertText": "WITH RECURSIVE tree AS (\n SELECT ${1:id}, ${2:name}, ${3:parent_id}, 0 AS depth, ${2:name}::TEXT AS path\n FROM ${4:table}\n WHERE ${3:parent_id} IS NULL\n UNION ALL\n SELECT c.${1:id}, c.${2:name}, c.${3:parent_id}, t.depth + 1,\n t.path || ' > ' || c.${2:name}\n FROM ${4:table} c\n JOIN tree t ON c.${3:parent_id} = t.${1:id}\n)\nSELECT * FROM tree ORDER BY path;",
|
|
280
2311
|
"insertTextRules": 4,
|
|
281
|
-
"sortText": "
|
|
2312
|
+
"sortText": "00_recursive_tree"
|
|
282
2313
|
},
|
|
283
2314
|
{
|
|
284
|
-
"label": "
|
|
285
|
-
"kind":
|
|
286
|
-
"detail": "
|
|
287
|
-
"documentation": {
|
|
288
|
-
|
|
2315
|
+
"label": "Audit trigger",
|
|
2316
|
+
"kind": 15,
|
|
2317
|
+
"detail": "Audit trigger function (PostgreSQL)",
|
|
2318
|
+
"documentation": {
|
|
2319
|
+
"value": "Trigger to log changes.\n\n```sql\nCREATE OR REPLACE FUNCTION audit_trigger()\nRETURNS TRIGGER AS $$\nBEGIN\n INSERT INTO audit_log (table_name, action, old_data, new_data, changed_at)\n VALUES (TG_TABLE_NAME, TG_OP, row_to_json(OLD), row_to_json(NEW), NOW());\n RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;\n```"
|
|
2320
|
+
},
|
|
2321
|
+
"insertText": "CREATE OR REPLACE FUNCTION ${1:audit_trigger}()\nRETURNS TRIGGER AS $$\nBEGIN\n INSERT INTO ${2:audit_log} (table_name, action, old_data, new_data, changed_at)\n VALUES (TG_TABLE_NAME, TG_OP, row_to_json(OLD), row_to_json(NEW), NOW());\n RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;\n\nCREATE TRIGGER ${3:trg_audit}\nAFTER ${4|INSERT,UPDATE,DELETE|} ON ${5:table}\nFOR EACH ROW\nEXECUTE FUNCTION ${1:audit_trigger}();",
|
|
289
2322
|
"insertTextRules": 4,
|
|
290
|
-
"sortText": "
|
|
2323
|
+
"sortText": "00_audit_trigger"
|
|
291
2324
|
},
|
|
292
2325
|
{
|
|
293
|
-
"label": "
|
|
2326
|
+
"label": "Pivot / Crosstab",
|
|
294
2327
|
"kind": 15,
|
|
295
|
-
"detail": "
|
|
296
|
-
"documentation": {
|
|
297
|
-
|
|
2328
|
+
"detail": "Pivot query",
|
|
2329
|
+
"documentation": {
|
|
2330
|
+
"value": "Pivot rows to columns using CASE.\n\n```sql\nSELECT product,\n SUM(CASE WHEN month = 'Jan' THEN revenue END) AS jan,\n SUM(CASE WHEN month = 'Feb' THEN revenue END) AS feb\nFROM sales\nGROUP BY product;\n```"
|
|
2331
|
+
},
|
|
2332
|
+
"insertText": "SELECT ${1:group_col},\n SUM(CASE WHEN ${2:pivot_col} = '${3:val1}' THEN ${4:measure} END) AS ${5:alias1},\n SUM(CASE WHEN ${2:pivot_col} = '${6:val2}' THEN ${4:measure} END) AS ${7:alias2}\nFROM ${8:table}\nGROUP BY ${1:group_col};",
|
|
298
2333
|
"insertTextRules": 4,
|
|
299
|
-
"sortText": "
|
|
2334
|
+
"sortText": "00_pivot_/_crosstab"
|
|
300
2335
|
},
|
|
301
2336
|
{
|
|
302
|
-
"label": "
|
|
2337
|
+
"label": "LIKE",
|
|
303
2338
|
"kind": 14,
|
|
304
|
-
"detail": "
|
|
305
|
-
"documentation": {
|
|
306
|
-
|
|
2339
|
+
"detail": "Pattern matching",
|
|
2340
|
+
"documentation": {
|
|
2341
|
+
"value": "Pattern matching with wildcards.\n\n```sql\nSELECT * FROM users WHERE name LIKE '%john%';\n-- % = any chars, _ = single char\n```"
|
|
2342
|
+
},
|
|
2343
|
+
"insertText": "LIKE '${1:%pattern%}'",
|
|
307
2344
|
"insertTextRules": 4,
|
|
308
|
-
"sortText": "
|
|
2345
|
+
"sortText": "02_like"
|
|
309
2346
|
},
|
|
310
2347
|
{
|
|
311
|
-
"label": "
|
|
2348
|
+
"label": "ILIKE",
|
|
312
2349
|
"kind": 14,
|
|
313
|
-
"detail": "
|
|
314
|
-
"documentation": {
|
|
315
|
-
|
|
2350
|
+
"detail": "Case-insensitive LIKE (PostgreSQL)",
|
|
2351
|
+
"documentation": {
|
|
2352
|
+
"value": "Case-insensitive pattern matching (PostgreSQL).\n\n```sql\nSELECT * FROM users WHERE name ILIKE '%john%';\n```"
|
|
2353
|
+
},
|
|
2354
|
+
"insertText": "ILIKE '${1:%pattern%}'",
|
|
316
2355
|
"insertTextRules": 4,
|
|
317
|
-
"sortText": "
|
|
2356
|
+
"sortText": "02_ilike"
|
|
318
2357
|
},
|
|
319
2358
|
{
|
|
320
|
-
"label": "
|
|
2359
|
+
"label": "BETWEEN",
|
|
321
2360
|
"kind": 14,
|
|
322
|
-
"detail": "
|
|
323
|
-
"documentation": {
|
|
324
|
-
|
|
2361
|
+
"detail": "Range predicate",
|
|
2362
|
+
"documentation": {
|
|
2363
|
+
"value": "Test if value is within a range (inclusive).\n\n```sql\nSELECT * FROM orders WHERE created_at BETWEEN '2024-01-01' AND '2024-12-31';\n```"
|
|
2364
|
+
},
|
|
2365
|
+
"insertText": "BETWEEN ${1:start} AND ${2:end}",
|
|
325
2366
|
"insertTextRules": 4,
|
|
326
|
-
"sortText": "
|
|
2367
|
+
"sortText": "02_between"
|
|
327
2368
|
},
|
|
328
2369
|
{
|
|
329
2370
|
"label": "IN",
|
|
330
2371
|
"kind": 14,
|
|
331
|
-
"detail": "
|
|
332
|
-
"documentation": {
|
|
2372
|
+
"detail": "Set membership",
|
|
2373
|
+
"documentation": {
|
|
2374
|
+
"value": "Test if value matches any in a list.\n\n```sql\nSELECT * FROM users WHERE role IN ('admin', 'editor', 'moderator');\n```"
|
|
2375
|
+
},
|
|
333
2376
|
"insertText": "IN (${1:values})",
|
|
334
2377
|
"insertTextRules": 4,
|
|
335
|
-
"sortText": "
|
|
2378
|
+
"sortText": "02_in"
|
|
336
2379
|
},
|
|
337
2380
|
{
|
|
338
2381
|
"label": "NOT IN",
|
|
339
2382
|
"kind": 14,
|
|
340
|
-
"detail": "Exclude
|
|
341
|
-
"documentation": {
|
|
2383
|
+
"detail": "Exclude set members",
|
|
2384
|
+
"documentation": {
|
|
2385
|
+
"value": "Test if value is not in a list.\n\n```sql\nSELECT * FROM users WHERE status NOT IN ('banned', 'deleted');\n```"
|
|
2386
|
+
},
|
|
342
2387
|
"insertText": "NOT IN (${1:values})",
|
|
343
2388
|
"insertTextRules": 4,
|
|
344
|
-
"sortText": "
|
|
2389
|
+
"sortText": "02_not_in"
|
|
345
2390
|
},
|
|
346
2391
|
{
|
|
347
|
-
"label": "
|
|
2392
|
+
"label": "EXISTS",
|
|
348
2393
|
"kind": 14,
|
|
349
|
-
"detail": "
|
|
350
|
-
"documentation": {
|
|
351
|
-
|
|
2394
|
+
"detail": "Existence subquery",
|
|
2395
|
+
"documentation": {
|
|
2396
|
+
"value": "Test if subquery returns any rows.\n\n```sql\nSELECT * FROM users u WHERE EXISTS (\n SELECT 1 FROM orders o WHERE o.user_id = u.id\n);\n```"
|
|
2397
|
+
},
|
|
2398
|
+
"insertText": "EXISTS (\n\tSELECT 1 FROM ${1:table} WHERE ${2:condition}\n)",
|
|
352
2399
|
"insertTextRules": 4,
|
|
353
|
-
"sortText": "
|
|
2400
|
+
"sortText": "02_exists"
|
|
354
2401
|
},
|
|
355
2402
|
{
|
|
356
|
-
"label": "
|
|
2403
|
+
"label": "ANY",
|
|
357
2404
|
"kind": 14,
|
|
358
|
-
"detail": "
|
|
359
|
-
"documentation": {
|
|
360
|
-
|
|
2405
|
+
"detail": "Compare to any subquery result",
|
|
2406
|
+
"documentation": {
|
|
2407
|
+
"value": "Compare to any value returned by subquery.\n\n```sql\nSELECT * FROM products WHERE price > ANY (SELECT price FROM discounted);\n```"
|
|
2408
|
+
},
|
|
2409
|
+
"insertText": "ANY (${1:subquery})",
|
|
361
2410
|
"insertTextRules": 4,
|
|
362
|
-
"sortText": "
|
|
2411
|
+
"sortText": "02_any"
|
|
363
2412
|
},
|
|
364
2413
|
{
|
|
365
|
-
"label": "
|
|
366
|
-
"kind":
|
|
367
|
-
"detail": "
|
|
368
|
-
"documentation": {
|
|
369
|
-
|
|
2414
|
+
"label": "ALL",
|
|
2415
|
+
"kind": 14,
|
|
2416
|
+
"detail": "Compare to all subquery results",
|
|
2417
|
+
"documentation": {
|
|
2418
|
+
"value": "Compare to all values returned by subquery.\n\n```sql\nSELECT * FROM products WHERE price > ALL (SELECT price FROM competitor_prices);\n```"
|
|
2419
|
+
},
|
|
2420
|
+
"insertText": "ALL (${1:subquery})",
|
|
370
2421
|
"insertTextRules": 4,
|
|
371
|
-
"sortText": "
|
|
2422
|
+
"sortText": "02_all"
|
|
372
2423
|
},
|
|
373
2424
|
{
|
|
374
|
-
"label": "
|
|
2425
|
+
"label": "IS NULL",
|
|
375
2426
|
"kind": 14,
|
|
376
|
-
"detail": "
|
|
377
|
-
"documentation": {
|
|
378
|
-
|
|
2427
|
+
"detail": "NULL check",
|
|
2428
|
+
"documentation": {
|
|
2429
|
+
"value": "Test for NULL values.\n\n```sql\nSELECT * FROM users WHERE deleted_at IS NULL;\n```"
|
|
2430
|
+
},
|
|
2431
|
+
"insertText": "IS NULL",
|
|
379
2432
|
"insertTextRules": 4,
|
|
380
|
-
"sortText": "
|
|
2433
|
+
"sortText": "02_is_null"
|
|
381
2434
|
},
|
|
382
2435
|
{
|
|
383
|
-
"label": "
|
|
384
|
-
"kind":
|
|
385
|
-
"detail": "
|
|
386
|
-
"documentation": {
|
|
387
|
-
|
|
2436
|
+
"label": "IS NOT NULL",
|
|
2437
|
+
"kind": 14,
|
|
2438
|
+
"detail": "NOT NULL check",
|
|
2439
|
+
"documentation": {
|
|
2440
|
+
"value": "Test for non-NULL values.\n\n```sql\nSELECT * FROM users WHERE email IS NOT NULL;\n```"
|
|
2441
|
+
},
|
|
2442
|
+
"insertText": "IS NOT NULL",
|
|
388
2443
|
"insertTextRules": 4,
|
|
389
|
-
"sortText": "
|
|
2444
|
+
"sortText": "02_is_not_null"
|
|
390
2445
|
},
|
|
391
2446
|
{
|
|
392
|
-
"label": "
|
|
393
|
-
"kind":
|
|
394
|
-
"detail": "
|
|
395
|
-
"documentation": {
|
|
396
|
-
|
|
2447
|
+
"label": "HAVING",
|
|
2448
|
+
"kind": 14,
|
|
2449
|
+
"detail": "Filter grouped results",
|
|
2450
|
+
"documentation": {
|
|
2451
|
+
"value": "Filter groups after GROUP BY.\n\n```sql\nSELECT department, COUNT(*) as cnt\nFROM employees\nGROUP BY department\nHAVING COUNT(*) > 5;\n```"
|
|
2452
|
+
},
|
|
2453
|
+
"insertText": "HAVING ${1:condition}",
|
|
397
2454
|
"insertTextRules": 4,
|
|
398
|
-
"sortText": "
|
|
2455
|
+
"sortText": "02_having"
|
|
399
2456
|
},
|
|
400
2457
|
{
|
|
401
|
-
"label": "
|
|
2458
|
+
"label": "CREATE ROLE",
|
|
402
2459
|
"kind": 14,
|
|
403
|
-
"detail": "
|
|
404
|
-
"documentation": {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
"
|
|
2460
|
+
"detail": "Create role/user",
|
|
2461
|
+
"documentation": {
|
|
2462
|
+
"value": "Create a database role.\n\n```sql\nCREATE ROLE app_user WITH LOGIN PASSWORD 'secret' VALID UNTIL '2025-12-31';\n```"
|
|
2463
|
+
},
|
|
2464
|
+
"insertText": "CREATE ROLE ${1:name} WITH ${2|LOGIN,NOLOGIN|} PASSWORD '${3:password}';",
|
|
2465
|
+
"insertTextRules": 4,
|
|
2466
|
+
"sortText": "03_create_role"
|
|
408
2467
|
},
|
|
409
2468
|
{
|
|
410
|
-
"label": "
|
|
2469
|
+
"label": "ALTER ROLE",
|
|
411
2470
|
"kind": 14,
|
|
412
|
-
"detail": "
|
|
413
|
-
"documentation": {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
"
|
|
2471
|
+
"detail": "Modify role",
|
|
2472
|
+
"documentation": {
|
|
2473
|
+
"value": "Modify role properties.\n\n```sql\nALTER ROLE app_user SET search_path TO myschema, public;\n```"
|
|
2474
|
+
},
|
|
2475
|
+
"insertText": "ALTER ROLE ${1:name} ${2|SET,SUPERUSER,CREATEDB,CREATEROLE,NOLOGIN|};",
|
|
2476
|
+
"insertTextRules": 4,
|
|
2477
|
+
"sortText": "03_alter_role"
|
|
417
2478
|
},
|
|
418
2479
|
{
|
|
419
|
-
"label": "
|
|
2480
|
+
"label": "DROP ROLE",
|
|
420
2481
|
"kind": 14,
|
|
421
|
-
"detail": "
|
|
422
|
-
"documentation": {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
"
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
"label": "COUNT",
|
|
429
|
-
"kind": 1,
|
|
430
|
-
"detail": "Count rows",
|
|
431
|
-
"documentation": { "value": "Returns the number of rows matching the query. COUNT(*) counts all rows; COUNT(column) counts non-NULL values." },
|
|
432
|
-
"insertText": "COUNT(${1:*})",
|
|
2482
|
+
"detail": "Drop role",
|
|
2483
|
+
"documentation": {
|
|
2484
|
+
"value": "Remove a database role.\n\n```sql\nDROP ROLE IF EXISTS old_user;\n```"
|
|
2485
|
+
},
|
|
2486
|
+
"insertText": "DROP ROLE IF EXISTS ${1:name};",
|
|
433
2487
|
"insertTextRules": 4,
|
|
434
|
-
"sortText": "
|
|
2488
|
+
"sortText": "03_drop_role"
|
|
435
2489
|
},
|
|
436
2490
|
{
|
|
437
|
-
"label": "
|
|
438
|
-
"kind":
|
|
439
|
-
"detail": "
|
|
440
|
-
"documentation": {
|
|
441
|
-
|
|
2491
|
+
"label": "CREATE DATABASE",
|
|
2492
|
+
"kind": 14,
|
|
2493
|
+
"detail": "Create database",
|
|
2494
|
+
"documentation": {
|
|
2495
|
+
"value": "Create new database.\n\n```sql\nCREATE DATABASE mydb\n OWNER = app_user\n ENCODING = 'UTF8'\n LC_COLLATE = 'en_US.UTF-8';\n```"
|
|
2496
|
+
},
|
|
2497
|
+
"insertText": "CREATE DATABASE ${1:name}\n\tOWNER = ${2:owner}\n\tENCODING = '${3:UTF8}';",
|
|
442
2498
|
"insertTextRules": 4,
|
|
443
|
-
"sortText": "
|
|
2499
|
+
"sortText": "03_create_db"
|
|
444
2500
|
},
|
|
445
2501
|
{
|
|
446
|
-
"label": "
|
|
447
|
-
"kind":
|
|
448
|
-
"detail": "
|
|
449
|
-
"documentation": {
|
|
450
|
-
|
|
2502
|
+
"label": "DROP DATABASE",
|
|
2503
|
+
"kind": 14,
|
|
2504
|
+
"detail": "Drop database",
|
|
2505
|
+
"documentation": {
|
|
2506
|
+
"value": "Delete a database.\n\n```sql\nDROP DATABASE IF EXISTS old_db;\n```"
|
|
2507
|
+
},
|
|
2508
|
+
"insertText": "DROP DATABASE IF EXISTS ${1:name};",
|
|
451
2509
|
"insertTextRules": 4,
|
|
452
|
-
"sortText": "
|
|
2510
|
+
"sortText": "03_drop_db"
|
|
453
2511
|
},
|
|
454
2512
|
{
|
|
455
|
-
"label": "
|
|
456
|
-
"kind":
|
|
457
|
-
"detail": "
|
|
458
|
-
"documentation": {
|
|
459
|
-
|
|
2513
|
+
"label": "SERIAL",
|
|
2514
|
+
"kind": 14,
|
|
2515
|
+
"detail": "Auto-increment integer",
|
|
2516
|
+
"documentation": {
|
|
2517
|
+
"value": "Auto-incrementing integer (PostgreSQL).\n\n```sql\nCREATE TABLE items (\n id SERIAL PRIMARY KEY\n);\n```"
|
|
2518
|
+
},
|
|
2519
|
+
"insertText": "SERIAL",
|
|
460
2520
|
"insertTextRules": 4,
|
|
461
|
-
"sortText": "
|
|
2521
|
+
"sortText": "04_serial"
|
|
462
2522
|
},
|
|
463
2523
|
{
|
|
464
|
-
"label": "
|
|
465
|
-
"kind":
|
|
466
|
-
"detail": "
|
|
467
|
-
"documentation": {
|
|
468
|
-
|
|
2524
|
+
"label": "UUID",
|
|
2525
|
+
"kind": 14,
|
|
2526
|
+
"detail": "UUID data type",
|
|
2527
|
+
"documentation": {
|
|
2528
|
+
"value": "UUID column type.\n\n```sql\nCREATE TABLE items (\n id UUID DEFAULT gen_random_uuid() PRIMARY KEY\n);\n```"
|
|
2529
|
+
},
|
|
2530
|
+
"insertText": "UUID DEFAULT gen_random_uuid()",
|
|
469
2531
|
"insertTextRules": 4,
|
|
470
|
-
"sortText": "
|
|
2532
|
+
"sortText": "04_uuid"
|
|
471
2533
|
},
|
|
472
2534
|
{
|
|
473
|
-
"label": "
|
|
474
|
-
"kind":
|
|
475
|
-
"detail": "
|
|
476
|
-
"documentation": {
|
|
477
|
-
|
|
2535
|
+
"label": "JSONB",
|
|
2536
|
+
"kind": 14,
|
|
2537
|
+
"detail": "JSONB data type (PostgreSQL)",
|
|
2538
|
+
"documentation": {
|
|
2539
|
+
"value": "Binary JSON type with indexing support.\n\n```sql\nCREATE TABLE events (\n id SERIAL PRIMARY KEY,\n data JSONB NOT NULL DEFAULT '{}'\n);\n```"
|
|
2540
|
+
},
|
|
2541
|
+
"insertText": "JSONB${1: NOT NULL DEFAULT '\\{\\}'}",
|
|
478
2542
|
"insertTextRules": 4,
|
|
479
|
-
"sortText": "
|
|
2543
|
+
"sortText": "04_jsonb"
|
|
480
2544
|
},
|
|
481
2545
|
{
|
|
482
|
-
"label": "
|
|
483
|
-
"kind":
|
|
484
|
-
"detail": "
|
|
485
|
-
"documentation": {
|
|
486
|
-
|
|
2546
|
+
"label": "TIMESTAMP WITH TIME ZONE",
|
|
2547
|
+
"kind": 14,
|
|
2548
|
+
"detail": "Timestamptz type",
|
|
2549
|
+
"documentation": {
|
|
2550
|
+
"value": "Timestamp with timezone.\n\n```sql\ncreated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()\n```"
|
|
2551
|
+
},
|
|
2552
|
+
"insertText": "TIMESTAMP WITH TIME ZONE DEFAULT ${1:NOW()}",
|
|
487
2553
|
"insertTextRules": 4,
|
|
488
|
-
"sortText": "
|
|
2554
|
+
"sortText": "04_timestamptz"
|
|
489
2555
|
},
|
|
490
2556
|
{
|
|
491
|
-
"label": "
|
|
492
|
-
"kind":
|
|
493
|
-
"detail": "
|
|
494
|
-
"documentation": {
|
|
495
|
-
|
|
2557
|
+
"label": "TEXT",
|
|
2558
|
+
"kind": 14,
|
|
2559
|
+
"detail": "Text data type",
|
|
2560
|
+
"documentation": {
|
|
2561
|
+
"value": "Variable-length text.\n\n```sql\nname TEXT NOT NULL\n```"
|
|
2562
|
+
},
|
|
2563
|
+
"insertText": "TEXT",
|
|
496
2564
|
"insertTextRules": 4,
|
|
497
|
-
"sortText": "
|
|
2565
|
+
"sortText": "04_text"
|
|
498
2566
|
},
|
|
499
2567
|
{
|
|
500
|
-
"label": "
|
|
501
|
-
"kind":
|
|
502
|
-
"detail": "
|
|
503
|
-
"documentation": {
|
|
504
|
-
|
|
2568
|
+
"label": "NUMERIC",
|
|
2569
|
+
"kind": 14,
|
|
2570
|
+
"detail": "Exact numeric type",
|
|
2571
|
+
"documentation": {
|
|
2572
|
+
"value": "Exact numeric with precision and scale.\n\n```sql\nprice NUMERIC(10, 2)\n```"
|
|
2573
|
+
},
|
|
2574
|
+
"insertText": "NUMERIC(${1:10}, ${2:2})",
|
|
505
2575
|
"insertTextRules": 4,
|
|
506
|
-
"sortText": "
|
|
2576
|
+
"sortText": "04_numeric"
|
|
507
2577
|
},
|
|
508
2578
|
{
|
|
509
|
-
"label": "
|
|
510
|
-
"kind":
|
|
511
|
-
"detail": "
|
|
512
|
-
"documentation": {
|
|
513
|
-
|
|
2579
|
+
"label": "VARCHAR",
|
|
2580
|
+
"kind": 14,
|
|
2581
|
+
"detail": "Variable-length character",
|
|
2582
|
+
"documentation": {
|
|
2583
|
+
"value": "Variable-length string with limit.\n\n```sql\nemail VARCHAR(255) NOT NULL UNIQUE\n```"
|
|
2584
|
+
},
|
|
2585
|
+
"insertText": "VARCHAR(${1:255})",
|
|
514
2586
|
"insertTextRules": 4,
|
|
515
|
-
"sortText": "
|
|
2587
|
+
"sortText": "04_varchar"
|
|
516
2588
|
},
|
|
517
2589
|
{
|
|
518
|
-
"label": "
|
|
519
|
-
"kind":
|
|
520
|
-
"detail": "
|
|
521
|
-
"documentation": {
|
|
522
|
-
|
|
2590
|
+
"label": "INTEGER",
|
|
2591
|
+
"kind": 14,
|
|
2592
|
+
"detail": "Integer type",
|
|
2593
|
+
"documentation": {
|
|
2594
|
+
"value": "32-bit integer.\n\n```sql\nage INTEGER CHECK (age >= 0)\n```"
|
|
2595
|
+
},
|
|
2596
|
+
"insertText": "INTEGER",
|
|
523
2597
|
"insertTextRules": 4,
|
|
524
|
-
"sortText": "
|
|
2598
|
+
"sortText": "04_integer"
|
|
525
2599
|
},
|
|
526
2600
|
{
|
|
527
|
-
"label": "
|
|
528
|
-
"kind":
|
|
529
|
-
"detail": "
|
|
530
|
-
"documentation": {
|
|
531
|
-
|
|
2601
|
+
"label": "DECIMAL",
|
|
2602
|
+
"kind": 14,
|
|
2603
|
+
"detail": "Decimal type",
|
|
2604
|
+
"documentation": {
|
|
2605
|
+
"value": "Exact decimal number.\n\n```sql\namount DECIMAL(12, 4)\n```"
|
|
2606
|
+
},
|
|
2607
|
+
"insertText": "DECIMAL(${1:12}, ${2:2})",
|
|
532
2608
|
"insertTextRules": 4,
|
|
533
|
-
"sortText": "
|
|
2609
|
+
"sortText": "04_decimal"
|
|
534
2610
|
},
|
|
535
2611
|
{
|
|
536
|
-
"label": "
|
|
537
|
-
"kind":
|
|
538
|
-
"detail": "
|
|
539
|
-
"documentation": {
|
|
540
|
-
|
|
2612
|
+
"label": "PRIMARY KEY",
|
|
2613
|
+
"kind": 14,
|
|
2614
|
+
"detail": "Primary key constraint",
|
|
2615
|
+
"documentation": {
|
|
2616
|
+
"value": "Define primary key.\n\n```sql\nid INTEGER PRIMARY KEY\n-- or table-level:\nPRIMARY KEY (col1, col2)\n```"
|
|
2617
|
+
},
|
|
2618
|
+
"insertText": "PRIMARY KEY${1: (${2:column})}",
|
|
541
2619
|
"insertTextRules": 4,
|
|
542
|
-
"sortText": "
|
|
2620
|
+
"sortText": "04_pk"
|
|
543
2621
|
},
|
|
544
2622
|
{
|
|
545
|
-
"label": "
|
|
546
|
-
"kind":
|
|
547
|
-
"detail": "
|
|
548
|
-
"documentation": {
|
|
549
|
-
|
|
2623
|
+
"label": "FOREIGN KEY",
|
|
2624
|
+
"kind": 14,
|
|
2625
|
+
"detail": "Foreign key constraint",
|
|
2626
|
+
"documentation": {
|
|
2627
|
+
"value": "Define foreign key relationship.\n\n```sql\nFOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE\n```"
|
|
2628
|
+
},
|
|
2629
|
+
"insertText": "FOREIGN KEY (${1:column}) REFERENCES ${2:table}(${3:id}) ON DELETE ${4|CASCADE,SET NULL,RESTRICT,NO ACTION|}",
|
|
550
2630
|
"insertTextRules": 4,
|
|
551
|
-
"sortText": "
|
|
2631
|
+
"sortText": "04_fk"
|
|
552
2632
|
},
|
|
553
2633
|
{
|
|
554
|
-
"label": "
|
|
555
|
-
"kind":
|
|
556
|
-
"detail": "
|
|
557
|
-
"documentation": {
|
|
558
|
-
|
|
2634
|
+
"label": "UNIQUE",
|
|
2635
|
+
"kind": 14,
|
|
2636
|
+
"detail": "Unique constraint",
|
|
2637
|
+
"documentation": {
|
|
2638
|
+
"value": "Ensure column uniqueness.\n\n```sql\nemail VARCHAR(255) UNIQUE\n-- or table-level:\nUNIQUE (email, tenant_id)\n```"
|
|
2639
|
+
},
|
|
2640
|
+
"insertText": "UNIQUE${1: (${2:columns})}",
|
|
559
2641
|
"insertTextRules": 4,
|
|
560
|
-
"sortText": "
|
|
2642
|
+
"sortText": "04_unique"
|
|
561
2643
|
},
|
|
562
2644
|
{
|
|
563
|
-
"label": "
|
|
564
|
-
"kind":
|
|
565
|
-
"detail": "
|
|
566
|
-
"documentation": {
|
|
567
|
-
|
|
2645
|
+
"label": "CHECK",
|
|
2646
|
+
"kind": 14,
|
|
2647
|
+
"detail": "Check constraint",
|
|
2648
|
+
"documentation": {
|
|
2649
|
+
"value": "Add check constraint.\n\n```sql\nCHECK (price >= 0)\nCHECK (status IN ('active', 'inactive', 'pending'))\n```"
|
|
2650
|
+
},
|
|
2651
|
+
"insertText": "CHECK (${1:condition})",
|
|
568
2652
|
"insertTextRules": 4,
|
|
569
|
-
"sortText": "
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
"label": "NOW",
|
|
573
|
-
"kind": 1,
|
|
574
|
-
"detail": "Current date and time",
|
|
575
|
-
"documentation": { "value": "Returns the current date and time as a DATETIME value." },
|
|
576
|
-
"insertText": "NOW()",
|
|
577
|
-
"insertTextRules": 0,
|
|
578
|
-
"sortText": "12_NOW"
|
|
2653
|
+
"sortText": "04_check"
|
|
579
2654
|
},
|
|
580
2655
|
{
|
|
581
|
-
"label": "
|
|
2656
|
+
"label": "DEFAULT",
|
|
582
2657
|
"kind": 14,
|
|
583
|
-
"detail": "
|
|
584
|
-
"documentation": {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
"
|
|
2658
|
+
"detail": "Default value",
|
|
2659
|
+
"documentation": {
|
|
2660
|
+
"value": "Set column default.\n\n```sql\ncreated_at TIMESTAMP DEFAULT NOW()\nstatus VARCHAR(20) DEFAULT 'pending'\n```"
|
|
2661
|
+
},
|
|
2662
|
+
"insertText": "DEFAULT ${1:value}",
|
|
2663
|
+
"insertTextRules": 4,
|
|
2664
|
+
"sortText": "04_default"
|
|
588
2665
|
},
|
|
589
2666
|
{
|
|
590
|
-
"label": "
|
|
591
|
-
"kind":
|
|
592
|
-
"detail": "
|
|
593
|
-
"documentation": {
|
|
594
|
-
|
|
2667
|
+
"label": "NOT NULL",
|
|
2668
|
+
"kind": 14,
|
|
2669
|
+
"detail": "Not null constraint",
|
|
2670
|
+
"documentation": {
|
|
2671
|
+
"value": "Prevent NULL values.\n\n```sql\nname VARCHAR(100) NOT NULL\n```"
|
|
2672
|
+
},
|
|
2673
|
+
"insertText": "NOT NULL",
|
|
595
2674
|
"insertTextRules": 4,
|
|
596
|
-
"sortText": "
|
|
2675
|
+
"sortText": "04_not_null"
|
|
597
2676
|
},
|
|
598
2677
|
{
|
|
599
|
-
"label": "
|
|
600
|
-
"kind":
|
|
601
|
-
"detail": "
|
|
602
|
-
"documentation": {
|
|
603
|
-
|
|
2678
|
+
"label": "EXCEPT ALL",
|
|
2679
|
+
"kind": 14,
|
|
2680
|
+
"detail": "Except all (with duplicates)",
|
|
2681
|
+
"documentation": {
|
|
2682
|
+
"value": "Return rows from first query not in second, keeping duplicates.\n\n```sql\nSELECT * FROM table1 EXCEPT ALL SELECT * FROM table2;\n```"
|
|
2683
|
+
},
|
|
2684
|
+
"insertText": "EXCEPT ALL\n${1:SELECT}",
|
|
604
2685
|
"insertTextRules": 4,
|
|
605
|
-
"sortText": "
|
|
2686
|
+
"sortText": "02_except_all"
|
|
606
2687
|
},
|
|
607
2688
|
{
|
|
608
|
-
"label": "
|
|
609
|
-
"kind":
|
|
610
|
-
"detail": "
|
|
611
|
-
"documentation": {
|
|
612
|
-
|
|
2689
|
+
"label": "INTERSECT ALL",
|
|
2690
|
+
"kind": 14,
|
|
2691
|
+
"detail": "Intersect all (with duplicates)",
|
|
2692
|
+
"documentation": {
|
|
2693
|
+
"value": "Return common rows keeping duplicates.\n\n```sql\nSELECT * FROM table1 INTERSECT ALL SELECT * FROM table2;\n```"
|
|
2694
|
+
},
|
|
2695
|
+
"insertText": "INTERSECT ALL\n${1:SELECT}",
|
|
613
2696
|
"insertTextRules": 4,
|
|
614
|
-
"sortText": "
|
|
2697
|
+
"sortText": "02_intersect_all"
|
|
615
2698
|
},
|
|
616
2699
|
{
|
|
617
|
-
"label": "
|
|
2700
|
+
"label": "GENERATE_SERIES",
|
|
618
2701
|
"kind": 1,
|
|
619
|
-
"detail": "
|
|
620
|
-
"documentation": {
|
|
621
|
-
|
|
2702
|
+
"detail": "Generate series of values",
|
|
2703
|
+
"documentation": {
|
|
2704
|
+
"value": "Generate a series of values.\n\n```sql\nSELECT generate_series(1, 10);\nSELECT generate_series('2024-01-01'::date, '2024-12-31'::date, '1 month');\n```"
|
|
2705
|
+
},
|
|
2706
|
+
"insertText": "generate_series(${1:start}, ${2:stop}${3:, '${4:1 day}'})",
|
|
622
2707
|
"insertTextRules": 4,
|
|
623
|
-
"sortText": "
|
|
2708
|
+
"sortText": "01_generate_series"
|
|
624
2709
|
},
|
|
625
2710
|
{
|
|
626
|
-
"label": "
|
|
2711
|
+
"label": "UNNEST",
|
|
627
2712
|
"kind": 1,
|
|
628
|
-
"detail": "
|
|
629
|
-
"documentation": {
|
|
630
|
-
|
|
2713
|
+
"detail": "Expand array to rows",
|
|
2714
|
+
"documentation": {
|
|
2715
|
+
"value": "Expand an array to a set of rows.\n\n```sql\nSELECT unnest(ARRAY[1,2,3]);\nSELECT unnest('{a,b,c}'::text[]);\n```"
|
|
2716
|
+
},
|
|
2717
|
+
"insertText": "unnest(${1:array})",
|
|
631
2718
|
"insertTextRules": 4,
|
|
632
|
-
"sortText": "
|
|
2719
|
+
"sortText": "01_unnest"
|
|
633
2720
|
},
|
|
634
2721
|
{
|
|
635
|
-
"label": "
|
|
2722
|
+
"label": "ARRAY_LENGTH",
|
|
636
2723
|
"kind": 1,
|
|
637
|
-
"detail": "
|
|
638
|
-
"documentation": {
|
|
639
|
-
|
|
2724
|
+
"detail": "Array length",
|
|
2725
|
+
"documentation": {
|
|
2726
|
+
"value": "Get array length.\n\n```sql\nSELECT array_length(ARRAY[1,2,3], 1); -- 3\n```"
|
|
2727
|
+
},
|
|
2728
|
+
"insertText": "array_length(${1:array}, ${2:1})",
|
|
640
2729
|
"insertTextRules": 4,
|
|
641
|
-
"sortText": "
|
|
2730
|
+
"sortText": "01_array_length"
|
|
642
2731
|
},
|
|
643
2732
|
{
|
|
644
|
-
"label": "
|
|
2733
|
+
"label": "PERCENTILE_CONT",
|
|
645
2734
|
"kind": 1,
|
|
646
|
-
"detail": "
|
|
647
|
-
"documentation": {
|
|
648
|
-
|
|
2735
|
+
"detail": "Continuous percentile",
|
|
2736
|
+
"documentation": {
|
|
2737
|
+
"value": "Calculate continuous percentile.\n\n```sql\nSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY salary) AS median\nFROM employees;\n```"
|
|
2738
|
+
},
|
|
2739
|
+
"insertText": "percentile_cont(${1:0.5}) WITHIN GROUP (ORDER BY ${2:column})",
|
|
649
2740
|
"insertTextRules": 4,
|
|
650
|
-
"sortText": "
|
|
2741
|
+
"sortText": "01_percentile"
|
|
651
2742
|
},
|
|
652
2743
|
{
|
|
653
|
-
"label": "
|
|
2744
|
+
"label": "PERCENTILE_DISC",
|
|
654
2745
|
"kind": 1,
|
|
655
|
-
"detail": "
|
|
656
|
-
"documentation": {
|
|
657
|
-
|
|
2746
|
+
"detail": "Discrete percentile",
|
|
2747
|
+
"documentation": {
|
|
2748
|
+
"value": "Calculate discrete percentile.\n\n```sql\nSELECT percentile_disc(0.5) WITHIN GROUP (ORDER BY salary) FROM employees;\n```"
|
|
2749
|
+
},
|
|
2750
|
+
"insertText": "percentile_disc(${1:0.5}) WITHIN GROUP (ORDER BY ${2:column})",
|
|
658
2751
|
"insertTextRules": 4,
|
|
659
|
-
"sortText": "
|
|
2752
|
+
"sortText": "01_percentile_d"
|
|
660
2753
|
},
|
|
661
2754
|
{
|
|
662
|
-
"label": "
|
|
2755
|
+
"label": "STRING_TO_ARRAY",
|
|
663
2756
|
"kind": 1,
|
|
664
|
-
"detail": "
|
|
665
|
-
"documentation": {
|
|
666
|
-
|
|
2757
|
+
"detail": "Split string to array",
|
|
2758
|
+
"documentation": {
|
|
2759
|
+
"value": "Split string into array.\n\n```sql\nSELECT string_to_array('a,b,c', ','); -- {a,b,c}\n```"
|
|
2760
|
+
},
|
|
2761
|
+
"insertText": "string_to_array(${1:string}, '${2:,}')",
|
|
667
2762
|
"insertTextRules": 4,
|
|
668
|
-
"sortText": "
|
|
2763
|
+
"sortText": "01_str_to_arr"
|
|
669
2764
|
},
|
|
670
2765
|
{
|
|
671
|
-
"label": "
|
|
2766
|
+
"label": "ARRAY_TO_STRING",
|
|
672
2767
|
"kind": 1,
|
|
673
|
-
"detail": "
|
|
674
|
-
"documentation": {
|
|
675
|
-
|
|
2768
|
+
"detail": "Join array to string",
|
|
2769
|
+
"documentation": {
|
|
2770
|
+
"value": "Join array elements into string.\n\n```sql\nSELECT array_to_string(ARRAY[1,2,3], ', '); -- '1, 2, 3'\n```"
|
|
2771
|
+
},
|
|
2772
|
+
"insertText": "array_to_string(${1:array}, '${2:, }')",
|
|
676
2773
|
"insertTextRules": 4,
|
|
677
|
-
"sortText": "
|
|
2774
|
+
"sortText": "01_arr_to_str"
|
|
678
2775
|
},
|
|
679
2776
|
{
|
|
680
|
-
"label": "
|
|
681
|
-
"kind":
|
|
682
|
-
"detail": "
|
|
683
|
-
"documentation": {
|
|
684
|
-
|
|
2777
|
+
"label": "ENCODE",
|
|
2778
|
+
"kind": 1,
|
|
2779
|
+
"detail": "Encode binary data",
|
|
2780
|
+
"documentation": {
|
|
2781
|
+
"value": "Encode binary data to text.\n\n```sql\nSELECT encode(digest('hello', 'sha256'), 'hex');\n```"
|
|
2782
|
+
},
|
|
2783
|
+
"insertText": "encode(${1:data}, '${2|hex,base64,escape|}')",
|
|
685
2784
|
"insertTextRules": 4,
|
|
686
|
-
"sortText": "
|
|
2785
|
+
"sortText": "01_encode"
|
|
687
2786
|
},
|
|
688
2787
|
{
|
|
689
|
-
"label": "
|
|
690
|
-
"kind":
|
|
691
|
-
"detail": "
|
|
692
|
-
"documentation": {
|
|
693
|
-
|
|
2788
|
+
"label": "DECODE",
|
|
2789
|
+
"kind": 1,
|
|
2790
|
+
"detail": "Decode text to binary",
|
|
2791
|
+
"documentation": {
|
|
2792
|
+
"value": "Decode text to binary data.\n\n```sql\nSELECT decode('48656C6C6F', 'hex');\n```"
|
|
2793
|
+
},
|
|
2794
|
+
"insertText": "decode(${1:text}, '${2|hex,base64,escape|}')",
|
|
694
2795
|
"insertTextRules": 4,
|
|
695
|
-
"sortText": "
|
|
2796
|
+
"sortText": "01_decode"
|
|
696
2797
|
},
|
|
697
2798
|
{
|
|
698
|
-
"label": "
|
|
699
|
-
"kind":
|
|
700
|
-
"detail": "
|
|
701
|
-
"documentation": {
|
|
702
|
-
|
|
2799
|
+
"label": "MD5",
|
|
2800
|
+
"kind": 1,
|
|
2801
|
+
"detail": "MD5 hash",
|
|
2802
|
+
"documentation": {
|
|
2803
|
+
"value": "Calculate MD5 hash.\n\n```sql\nSELECT md5('hello'); -- '5d41402abc4b2a76b9719d911017c592'\n```"
|
|
2804
|
+
},
|
|
2805
|
+
"insertText": "md5(${1:string})",
|
|
703
2806
|
"insertTextRules": 4,
|
|
704
|
-
"sortText": "
|
|
2807
|
+
"sortText": "01_md5"
|
|
705
2808
|
},
|
|
706
2809
|
{
|
|
707
|
-
"label": "
|
|
708
|
-
"kind":
|
|
709
|
-
"detail": "
|
|
710
|
-
"documentation": {
|
|
711
|
-
|
|
2810
|
+
"label": "GEN_RANDOM_UUID",
|
|
2811
|
+
"kind": 1,
|
|
2812
|
+
"detail": "Generate UUID (PostgreSQL)",
|
|
2813
|
+
"documentation": {
|
|
2814
|
+
"value": "Generate random UUID.\n\n```sql\nSELECT gen_random_uuid();\n```"
|
|
2815
|
+
},
|
|
2816
|
+
"insertText": "gen_random_uuid()",
|
|
712
2817
|
"insertTextRules": 4,
|
|
713
|
-
"sortText": "
|
|
2818
|
+
"sortText": "01_uuid"
|
|
714
2819
|
},
|
|
715
2820
|
{
|
|
716
|
-
"label": "
|
|
717
|
-
"kind":
|
|
718
|
-
"detail": "
|
|
719
|
-
"documentation": {
|
|
720
|
-
|
|
2821
|
+
"label": "TO_NUMBER",
|
|
2822
|
+
"kind": 1,
|
|
2823
|
+
"detail": "Convert string to number",
|
|
2824
|
+
"documentation": {
|
|
2825
|
+
"value": "Convert text to numeric.\n\n```sql\nSELECT to_number('1,234.56', '9G999D99');\n```"
|
|
2826
|
+
},
|
|
2827
|
+
"insertText": "to_number(${1:text}, '${2:format}')",
|
|
721
2828
|
"insertTextRules": 4,
|
|
722
|
-
"sortText": "
|
|
2829
|
+
"sortText": "01_to_number"
|
|
723
2830
|
},
|
|
724
2831
|
{
|
|
725
|
-
"label": "
|
|
2832
|
+
"label": "BIGINT",
|
|
726
2833
|
"kind": 14,
|
|
727
|
-
"detail": "
|
|
728
|
-
"documentation": {
|
|
729
|
-
|
|
2834
|
+
"detail": "64-bit integer type",
|
|
2835
|
+
"documentation": {
|
|
2836
|
+
"value": "BIGINT: 64-bit signed integer."
|
|
2837
|
+
},
|
|
2838
|
+
"insertText": "BIGINT",
|
|
730
2839
|
"insertTextRules": 4,
|
|
731
|
-
"sortText": "
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
"label": "NOT NULL",
|
|
735
|
-
"kind": 14,
|
|
736
|
-
"detail": "Not null constraint",
|
|
737
|
-
"documentation": { "value": "Ensures a column cannot contain NULL values." },
|
|
738
|
-
"insertText": "NOT NULL",
|
|
739
|
-
"insertTextRules": 0,
|
|
740
|
-
"sortText": "14_NOT_NULL"
|
|
2840
|
+
"sortText": "04"
|
|
741
2841
|
},
|
|
742
2842
|
{
|
|
743
|
-
"label": "
|
|
2843
|
+
"label": "BIGSERIAL",
|
|
744
2844
|
"kind": 14,
|
|
745
|
-
"detail": "
|
|
746
|
-
"documentation": {
|
|
747
|
-
|
|
2845
|
+
"detail": "Auto-increment bigint",
|
|
2846
|
+
"documentation": {
|
|
2847
|
+
"value": "BIGSERIAL: auto-incrementing 64-bit integer."
|
|
2848
|
+
},
|
|
2849
|
+
"insertText": "BIGSERIAL",
|
|
748
2850
|
"insertTextRules": 4,
|
|
749
|
-
"sortText": "
|
|
2851
|
+
"sortText": "04"
|
|
750
2852
|
},
|
|
751
2853
|
{
|
|
752
|
-
"label": "
|
|
2854
|
+
"label": "SMALLINT",
|
|
753
2855
|
"kind": 14,
|
|
754
|
-
"detail": "
|
|
755
|
-
"documentation": {
|
|
756
|
-
|
|
2856
|
+
"detail": "16-bit integer type",
|
|
2857
|
+
"documentation": {
|
|
2858
|
+
"value": "SMALLINT: 16-bit signed integer."
|
|
2859
|
+
},
|
|
2860
|
+
"insertText": "SMALLINT",
|
|
757
2861
|
"insertTextRules": 4,
|
|
758
|
-
"sortText": "
|
|
2862
|
+
"sortText": "04"
|
|
759
2863
|
},
|
|
760
2864
|
{
|
|
761
|
-
"label": "
|
|
762
|
-
"kind":
|
|
763
|
-
"detail": "
|
|
764
|
-
"documentation": {
|
|
765
|
-
|
|
2865
|
+
"label": "BOOLEAN",
|
|
2866
|
+
"kind": 14,
|
|
2867
|
+
"detail": "Boolean type",
|
|
2868
|
+
"documentation": {
|
|
2869
|
+
"value": "Boolean: true/false."
|
|
2870
|
+
},
|
|
2871
|
+
"insertText": "BOOLEAN",
|
|
766
2872
|
"insertTextRules": 4,
|
|
767
|
-
"sortText": "
|
|
2873
|
+
"sortText": "04"
|
|
768
2874
|
},
|
|
769
2875
|
{
|
|
770
|
-
"label": "
|
|
2876
|
+
"label": "REAL",
|
|
771
2877
|
"kind": 14,
|
|
772
|
-
"detail": "
|
|
773
|
-
"documentation": {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
"
|
|
2878
|
+
"detail": "Float type",
|
|
2879
|
+
"documentation": {
|
|
2880
|
+
"value": "REAL: 32-bit floating point."
|
|
2881
|
+
},
|
|
2882
|
+
"insertText": "REAL",
|
|
2883
|
+
"insertTextRules": 4,
|
|
2884
|
+
"sortText": "04"
|
|
777
2885
|
},
|
|
778
2886
|
{
|
|
779
|
-
"label": "
|
|
2887
|
+
"label": "FLOAT",
|
|
780
2888
|
"kind": 14,
|
|
781
|
-
"detail": "
|
|
782
|
-
"documentation": {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
"
|
|
2889
|
+
"detail": "Floating point type",
|
|
2890
|
+
"documentation": {
|
|
2891
|
+
"value": "FLOAT: floating point number."
|
|
2892
|
+
},
|
|
2893
|
+
"insertText": "FLOAT",
|
|
2894
|
+
"insertTextRules": 4,
|
|
2895
|
+
"sortText": "04"
|
|
786
2896
|
},
|
|
787
2897
|
{
|
|
788
|
-
"label": "
|
|
2898
|
+
"label": "DATE",
|
|
789
2899
|
"kind": 14,
|
|
790
|
-
"detail": "
|
|
791
|
-
"documentation": {
|
|
792
|
-
|
|
2900
|
+
"detail": "Date type",
|
|
2901
|
+
"documentation": {
|
|
2902
|
+
"value": "DATE: calendar date (year, month, day)."
|
|
2903
|
+
},
|
|
2904
|
+
"insertText": "DATE",
|
|
793
2905
|
"insertTextRules": 4,
|
|
794
|
-
"sortText": "
|
|
2906
|
+
"sortText": "04"
|
|
795
2907
|
},
|
|
796
2908
|
{
|
|
797
|
-
"label": "
|
|
2909
|
+
"label": "TIMESTAMP",
|
|
798
2910
|
"kind": 14,
|
|
799
|
-
"detail": "
|
|
800
|
-
"documentation": {
|
|
801
|
-
|
|
2911
|
+
"detail": "Timestamp type",
|
|
2912
|
+
"documentation": {
|
|
2913
|
+
"value": "TIMESTAMP: date and time without timezone."
|
|
2914
|
+
},
|
|
2915
|
+
"insertText": "TIMESTAMP",
|
|
802
2916
|
"insertTextRules": 4,
|
|
803
|
-
"sortText": "
|
|
2917
|
+
"sortText": "04"
|
|
804
2918
|
},
|
|
805
2919
|
{
|
|
806
|
-
"label": "
|
|
2920
|
+
"label": "TIMESTAMPTZ",
|
|
807
2921
|
"kind": 14,
|
|
808
|
-
"detail": "
|
|
809
|
-
"documentation": {
|
|
810
|
-
|
|
2922
|
+
"detail": "Timestamp with timezone",
|
|
2923
|
+
"documentation": {
|
|
2924
|
+
"value": "TIMESTAMPTZ: timestamp with timezone."
|
|
2925
|
+
},
|
|
2926
|
+
"insertText": "TIMESTAMPTZ",
|
|
811
2927
|
"insertTextRules": 4,
|
|
812
|
-
"sortText": "
|
|
2928
|
+
"sortText": "04"
|
|
813
2929
|
},
|
|
814
2930
|
{
|
|
815
|
-
"label": "
|
|
2931
|
+
"label": "CHAR",
|
|
816
2932
|
"kind": 14,
|
|
817
|
-
"detail": "
|
|
818
|
-
"documentation": {
|
|
819
|
-
|
|
2933
|
+
"detail": "Fixed-length char",
|
|
2934
|
+
"documentation": {
|
|
2935
|
+
"value": "CHAR(n): fixed-length character string."
|
|
2936
|
+
},
|
|
2937
|
+
"insertText": "CHAR()",
|
|
820
2938
|
"insertTextRules": 4,
|
|
821
|
-
"sortText": "
|
|
2939
|
+
"sortText": "04"
|
|
822
2940
|
},
|
|
823
2941
|
{
|
|
824
|
-
"label": "
|
|
2942
|
+
"label": "BYTEA",
|
|
825
2943
|
"kind": 14,
|
|
826
|
-
"detail": "
|
|
827
|
-
"documentation": {
|
|
828
|
-
|
|
2944
|
+
"detail": "Binary data type",
|
|
2945
|
+
"documentation": {
|
|
2946
|
+
"value": "BYTEA: binary data (byte array)."
|
|
2947
|
+
},
|
|
2948
|
+
"insertText": "BYTEA",
|
|
829
2949
|
"insertTextRules": 4,
|
|
830
|
-
"sortText": "
|
|
2950
|
+
"sortText": "04"
|
|
831
2951
|
},
|
|
832
2952
|
{
|
|
833
|
-
"label": "
|
|
834
|
-
"kind":
|
|
835
|
-
"detail": "
|
|
836
|
-
"documentation": {
|
|
837
|
-
|
|
2953
|
+
"label": "JSON",
|
|
2954
|
+
"kind": 14,
|
|
2955
|
+
"detail": "JSON type",
|
|
2956
|
+
"documentation": {
|
|
2957
|
+
"value": "JSON: text-based JSON storage."
|
|
2958
|
+
},
|
|
2959
|
+
"insertText": "JSON",
|
|
838
2960
|
"insertTextRules": 4,
|
|
839
|
-
"sortText": "
|
|
2961
|
+
"sortText": "04"
|
|
840
2962
|
},
|
|
841
2963
|
{
|
|
842
|
-
"label": "
|
|
843
|
-
"kind":
|
|
844
|
-
"detail": "
|
|
845
|
-
"documentation": {
|
|
846
|
-
|
|
2964
|
+
"label": "ARRAY",
|
|
2965
|
+
"kind": 14,
|
|
2966
|
+
"detail": "Array type",
|
|
2967
|
+
"documentation": {
|
|
2968
|
+
"value": "ARRAY: array of any base type.\n\n```sql\ntags TEXT[] DEFAULT '{}'\n```"
|
|
2969
|
+
},
|
|
2970
|
+
"insertText": "ARRAY[]",
|
|
847
2971
|
"insertTextRules": 4,
|
|
848
|
-
"sortText": "
|
|
2972
|
+
"sortText": "04"
|
|
849
2973
|
},
|
|
850
2974
|
{
|
|
851
|
-
"label": "
|
|
2975
|
+
"label": "INET",
|
|
852
2976
|
"kind": 14,
|
|
853
|
-
"detail": "
|
|
854
|
-
"documentation": {
|
|
855
|
-
|
|
2977
|
+
"detail": "IP address type",
|
|
2978
|
+
"documentation": {
|
|
2979
|
+
"value": "INET: IPv4 or IPv6 host address."
|
|
2980
|
+
},
|
|
2981
|
+
"insertText": "INET",
|
|
856
2982
|
"insertTextRules": 4,
|
|
857
|
-
"sortText": "
|
|
2983
|
+
"sortText": "04"
|
|
858
2984
|
},
|
|
859
2985
|
{
|
|
860
|
-
"label": "
|
|
861
|
-
"kind":
|
|
862
|
-
"detail": "
|
|
863
|
-
"documentation": {
|
|
864
|
-
|
|
2986
|
+
"label": "CIDR",
|
|
2987
|
+
"kind": 14,
|
|
2988
|
+
"detail": "Network address type",
|
|
2989
|
+
"documentation": {
|
|
2990
|
+
"value": "CIDR: IPv4 or IPv6 network address."
|
|
2991
|
+
},
|
|
2992
|
+
"insertText": "CIDR",
|
|
865
2993
|
"insertTextRules": 4,
|
|
866
|
-
"sortText": "
|
|
2994
|
+
"sortText": "04"
|
|
867
2995
|
},
|
|
868
2996
|
{
|
|
869
|
-
"label": "
|
|
870
|
-
"kind":
|
|
871
|
-
"detail": "
|
|
872
|
-
"documentation": {
|
|
873
|
-
|
|
2997
|
+
"label": "ENUM",
|
|
2998
|
+
"kind": 14,
|
|
2999
|
+
"detail": "Enum shorthand",
|
|
3000
|
+
"documentation": {
|
|
3001
|
+
"value": "Enum type reference."
|
|
3002
|
+
},
|
|
3003
|
+
"insertText": "ENUM",
|
|
874
3004
|
"insertTextRules": 4,
|
|
875
|
-
"sortText": "
|
|
3005
|
+
"sortText": "04"
|
|
876
3006
|
},
|
|
877
3007
|
{
|
|
878
|
-
"label": "
|
|
879
|
-
"kind":
|
|
880
|
-
"detail": "
|
|
881
|
-
"documentation": {
|
|
882
|
-
|
|
3008
|
+
"label": "EXECUTE",
|
|
3009
|
+
"kind": 14,
|
|
3010
|
+
"detail": "Execute prepared statement",
|
|
3011
|
+
"documentation": {
|
|
3012
|
+
"value": "Execute a prepared statement.\n\n```sql\nEXECUTE stmt_name(param1, param2);\n```"
|
|
3013
|
+
},
|
|
3014
|
+
"insertText": "EXECUTE ();",
|
|
883
3015
|
"insertTextRules": 4,
|
|
884
|
-
"sortText": "
|
|
3016
|
+
"sortText": "02"
|
|
885
3017
|
}
|
|
886
3018
|
]
|
|
887
3019
|
}
|