SQL Snippets
SQL snippets appear as editor completion candidates. Accept a matching trigger to insert the template at the cursor, then use Tab and Shift+Tab to move through any editable placeholders.
Manage Snippets
Open Settings → Snippets. Each snippet contains:
| Field | Purpose |
|---|---|
| Label | Name shown in the completion list. DBX uses the prefix when the label is empty. |
| Prefix | Text that matches the completion candidate. It is required and must be unique in the current snippet list. |
| Status | Enables or disables the snippet without deleting it. |
| SQL Body | Template inserted into the editor when you accept the completion. |
You can add, edit, enable, disable, or delete snippets. Restore Defaults replaces the current draft with DBX's built-in snippets; click Apply in the settings dialog to persist your changes.
DBX includes common snippets such as sel, ins, upd, cte, and join. Some built-in templates adapt to the active database, for example by choosing the appropriate row-limit or ALTER TABLE syntax. Custom snippets are inserted exactly as written.
Expand a Snippet
- Type a prefix such as
selin the SQL editor. - Confirm the label and body preview in the completion list.
- Press
Tab,Enter, or click the candidate to accept it. - When the template has placeholders, press
Tabto move forward andShift+Tabto move back.
If no candidate appears, confirm that the snippet is enabled, the prefix matches the current text, and editor autocomplete is enabled.
Placeholder Syntax
DBX uses CodeMirror snippet syntax:
| Syntax | Purpose |
|---|---|
${} | Creates an empty editable field. |
${name} | Creates a field whose default text is name; repeated names are edited together. |
${1} | Sets an explicit field order. |
${1:defaultText} | Sets the order and provides default text. |
#{name} | Alternative form of ${name}. |
Numbered fields follow numeric order. Unnumbered fields follow their textual order in the template. Escape a literal opening or closing brace with a backslash when it must not be parsed as a placeholder.
For example:
SELECT ${1:columns}
FROM ${2:table}
WHERE ${3:condition}
ORDER BY ${4:column};Reuse a field to edit multiple locations together:
SELECT ${1:column}, COUNT(*) AS cnt
FROM ${2:table}
GROUP BY ${1:column};Storage, Sync, and Safety
Snippets are editor settings stored in the current DBX runtime. On Desktop, Configuration Cloud Sync can synchronize snippets with the other editor settings. Connection Config Migration only moves database connections and does not include snippets.
A snippet only generates SQL; it does not bypass database permissions or DBX production protection. Review the fully expanded statement before running templates that contain writes or DDL, and follow the Production Safety guidance.