On this page

BroadSQL cheat sheet

The commands you type most, the shortcuts and the keys, on one page. It prints on two sheets; every name links to its full reference.

First ten commands

CONNECT <id>;Open a connection
SHOW TABLES;List the tables
DESCR <table>;Its columns and types
CNT <table>;Count its rows
SELECT ...;Any SQL, sent as is
/Run the last query again
DUMP / TO f AS XLSX;Export what is on screen
HELP FIND <text>;Search the commands
DISCONNECT;Close the connection
exitQuit (lowercase, no ;)

Connections and environments

CONNECT <id> CONOpen a connection
ENV <environment>Same application, other Environment
/ PRODLast query once on PROD, stay here
SHOW CONNECTION SHCOWhere am I?
SHOW GROUP SHENVThe Environments of my application
SHOW ALL CONNECTIONS SHALCOEvery connection
PING <id> CHECKTest without opening
DISCONNECT BYEClose the connection
LOGOUTClose everything, ask the master password

Exploring

SHOW TABLES [CUST%] SHTATables, filtered by name
SHOW VIEWS SHVIViews
DESCR <table> [ALPHA] DESCColumns, in table or name order
SHOW PK <table> SHPKPrimary key
SHOW FK <table> SHFKWhat it references
SHOW REFERENCES <table> SHREFWhat references it
FIND COLUMN <text> FICOLWhere is that column?
COMPARE TABLE STRUCTURE <t> WITH <id>Same table, another connection
ALL <table> / CNT <table>Every row / the row count

Running queries again

/Run the last query again
// or SHOW QUERYShow it without running it
REPEAT EVERY 30s;Watch it until Ctrl+C
EXPANDReplace * by the column names
FORMATLay out the last query
SET LIST ONOne row at a time, as a form

Lists of values

IN <@clipboard>Values copied, one per line
IN <@last:ID>A column of the last result
IN <@ids.txt>A text file, one per line
IN <@csv:f.csv:ID>A named CSV column
IN <@excel:f.xlsx:Sheet:ID>A named Excel column

Export and load

DUMP <table> TO f AS CSVA whole table
DUMP (<query>) TO f.TAB AS XLSXA query, into one worksheet
DUMP / TO f AS MDWhat is on screen
... MODE APPENDAdd rows instead of replacing
DUMP t TO COPY.t AS H2 MODE MERGE KEY(ID)Keep a local copy fresh
COPY RESULTLast result to the clipboard
LOAD <table> f.csv PREVIEW LOCheck a CSV, then without PREVIEW

Formats: CSV, TEXT, JSON, XLSX, ODS, MD, HTML, H2.

Scripts

@dir/s.sql name=valueRun a Script of the library
LIB LIST [ALL] LILIList the Scripts
LIB FIND <text> LIFISearch their content
LIB SHOW <script> LISHContent and parameters
LIB LINT LILNCheck the library
LET x = 42;A variable, used as ${x}
ON ERROR STOP;Stop at the first failure
-- @param id INTEGER = 1A typed parameter
EDIT EDOpen the BroadSQL Editor

Console keys

TabComplete; again for the next candidate
Up DownEarlier commands, across sessions
Ctrl+RSearch the history
EscAbandon what you are typing
Ctrl+CStop the running command
Ctrl+LClear the screen
Ctrl+U / Ctrl+KDelete to the start / the end of the line

HELP SHORTCUTS; lists every key in the console.

Settings to know

DefaultFolderWhere DUMP writes
CsvSeparatorSEMICOLON (default) or COMMA
MaxRowsOnScreenRows shown on screen (0: no limit)
RememberLastConnectionReopen the last connection at startup
ProductionConfirmEveryChangeAsk before every change, or once per session
IsLogActivatedKeep the activity log

In conf/BroadSQL.ini (Windows) or conf/broadsqlux.ini (Linux), or in CONFIG: see Application settings.

Found something wrong or unclear on this page? , with the page address.