Syntax and shortcuts
BroadSQL adds a few forms to the SQL you type that are not commands: shortcuts that run a query again, list sources that expand to a list of values, and variables. This page lists them all in one place; each row links to the section that explains it.
| Form | What it does | Example | Details |
|---|---|---|---|
; | Ends every command, BroadSQL's own or SQL. A command may span several lines; it runs at its closing ;. A ; inside a quoted value is text. | SELECT 1; SELECT 2; | Entering commands |
/ | Runs the last SQL statement again, on the current connection. Typed on a line by itself. | / | Patterns: / |
/ <environment> | Runs the last SQL statement once on the connection of another Environment of the same Database Group, without switching. | / PROD | Patterns: / <environment> |
// | Shows the last query on one line without running it, like SHOW QUERY. | // | Entering commands |
@<script> [name=value ...] | Runs a Script: a plain name is in the Scripts Library, ./ is next to the current Script or the working directory, an absolute path is anywhere. | @countries/largest.sql continent='Europe' | Running Scripts |
${name} | A Script variable or argument, sent to the database as a typed value, never pasted into the SQL text. | WHERE CONTINENT = ${continent} | Variables |
<@file> | Expands to the values of a text file, one per line, quoted and separated by commas. | WHERE ID IN <@ids.txt> | Patterns: <@fileName> |
<@csv:<path>:<column>> | Expands to the values of one named column of a CSV file. | IN <@csv:c:\temp\review.csv:COUNTRY_CODE> | Patterns: <@csv:...> |
<@excel:<path>:<sheet>:<column>> | Expands to the values of one named column of one sheet of an .xlsx workbook. | IN <@excel:c:\temp\review.xlsx:Countries:COUNTRY_CODE> | Patterns: <@excel:...> |
<@last:<column>> | Expands to the values of one column of the result you just displayed, so one query feeds the next. | IN <@last:CODE> | Patterns: <@last:...> |
<@clipboard> | Expands to the values on the clipboard, one per line: a column copied from a spreadsheet or a ticket. | IN <@clipboard> | Patterns: <@clipboard> |
-- and /* */ | Comments, ignored in Scripts. A -- line at the top of a Script may hold a directive. | -- monthly check | Running Scripts |
exit | Ends BroadSQL and closes every connection cleanly. Lowercase, without ;. | exit | Entering commands |
:name | In a RUN URL, a runtime placeholder resolved for that call: a session VAR first, then the API environment, then the endpoint's saved value or default. | RUN /users/:id | API variables |
${ENV:NAME} | In an API definition, the value of an operating system environment variable, for example a token. | ${ENV:CRM_TOKEN} | API variables |
Rules for every line
- A command ends with
;, and may span several lines. Several commands may share a line; when one fails, the ones after it on that line are not run. /,/ <environment>,//andexitare typed on a line by themselves, without;.- A list source starts at
<@and ends at the first>after it, on the same line. Inside a quoted string or a comment,<@is ordinary text. ${name}is replaced by a typed value sent to the database, never by text: writeWHERE ID = ${id}, without quotes around it.- In a Script, statements are split at
;only, so a procedural block that contains;is split too.
Choosing a shortcut
Related
- Script directives: the
-- @...lines of a Script header. - Patterns and list sources
- Interactive console: keys, history and completion.
- Cheat sheet
Found something wrong or unclear on this page? Tell us, with the page address.