Skip to content

Command line options

The options of the command line of usql v0.19.13-0.20261129074835-be3acfadfc0c, as usql --help lists them. A command line has the options, then a URL or the name of a connection:

usql [OPTION]... [DSN]

An option that takes a value takes it after a space or after =, as-c 'select 1' or --command='select 1'.

General options

OptionDescription
-c, --command=COMMANDrun only single command (SQL or internal) and exit
-d, --dbname=DSNdatabase url or connection name to connect to
-f, --file=FILEexecute commands from file, then exit
-l, --listlist available databases, then exit
-v, --set=NAME=VALUEset script variable NAME to VALUE (see \set command) Also --variable.
-O, --option=NAME=VALUEset configuration option NAME (SECTION.NAME) to VALUE (see \config command)
-U, --uset=NAME=VALUEset setting NAME of usql to VALUE (see \uset command)
-N, --cset=NAME=DSNset named connection NAME to DSN (see \cset command)
-D, --dumpwrite the database as a usql script to standard output or to the file of -o, then exit
--config=FILEconfig file
-V, --versionoutput version information, then exit
-X, --no-initdo not execute initialization scripts
-1, --single-transactionexecute as a single transaction (if non-interactive)
-?, --help[=options]show this help, then exit
  • --help=options
  • --help=commands: list backslash commands, then exit
  • --help=variables: list variables and settings, then exit

Input and output options

OptionDescription
-E, --echo-hiddendisplay queries that internal commands generate
-o, --output=FILEsend query results to file
-q, --quietrun quietly (no messages, only query output)

Output format options

OptionDescription
-A, --no-alignunaligned table output mode
-C, --csvCSV output mode
-F, --field-separator=STRINGfield separator for unaligned and CSV output (default "|" and ",")
-G, --verticalvertical output mode
-H, --htmlHTML table output mode
-J, --jsonJSON output mode
-M, --markdownmarkdown output mode
-P, --pset=VAR=ARGset printing option VAR to ARG (see \pset command)
-R, --record-separator=STRINGrecord separator for unaligned and CSV output (default \n)
-t, --tuples-onlyprint rows only
-T, --table-attr=TEXTset HTML table tag attributes (e.g., width, border)
-x, --expandedturn on expanded table output
-z, --field-separator-zeroset field separator for unaligned and CSV output to zero byte
-0, --record-separator-zeroset record separator for unaligned and CSV output to zero byte

Connection options

OptionDescription
-w, --no-passwordnever prompt for password
-W, --passwordforce password prompt (should happen automatically)

Options of a dump

These options change what --dump writes. They are long options only, andusql --help does not list them. The meta command \dump takes the same options, as -schema-only.

OptionDescription
--target=DRIVERwrite the dump for another database, such as duckdb
--schema-onlydump the schema and no rows
--data-onlydump the rows and no schema
--schema=PATTERNdump the schemas that match PATTERN
--exclude-schema=PATTERNdo not dump the schemas that match PATTERN
--table=PATTERNdump the tables that match PATTERN
--exclude-table=PATTERNdo not dump the tables that match PATTERN
--allow-lossyallow a type of the target that holds less than the source type
--allow-textallow the string type of the target for a type that it does not have
--restrict-key=KEYthe key of the \restrict line of the dump