ybsql Command-Line Options
In addition to the connection options, you can specify a number of other options on the ybsql command line. See also ybsql Examples.
- -a, --echo-all
- Print all input lines to standard output as they are read. This does not apply to empty lines or lines read interactively. This option has the same effect as setting the
ECHOvariable toall. - -A, --no-align
- Switch the output to unaligned mode. The default output mode is aligned.
- -b, --echo-errors
- Print failed SQL commands to standard error output. This option has the same effect as setting the
ECHOvariable toerrors. - -c command --command=command
- Execute the contents of one command string, then exit. The command must be either a command string that does not contain any syntax specific to
ybsqlor a single backslash command (such as\d). If the command string contains multiple SQL commands, they are processed in a single transaction (except when the string includes explicitBEGIN/COMMITcommands). - -e, --echo-queries
- Copy all SQL commands to standard output. This option has the same effect as setting the
ECHOvariable toqueries. - -f filename, --file=filename
- Read commands from a named file instead of interactively, then exit (similar to using the
\icommand). If the specified file is-(a hyphen),ybsqlreads from standard input until anEOFor a\qcommand is found. - -F separator, --field-separator=separator
- Use the specified separator between fields for unaligned output (
-A). This option has the same effect as\pset fieldsepor\f. - -H, --html
- Return HTML tabular output. This option has the same effect as
\pset format htmlor\H. - --help
- Return a summary of the
ybsqlcommand-line options. - -l, --list
- List all available databases, then exit (similar to
\list). Other non-connection options are ignored. - -L filename --log-file=filename
- Send all query output to the specified file, in addition to the normal output destination.
- -o filename --output=filename
- Send all query output to the specified file only (no normal output, unlike
-L). This option is equivalent to the\ocommand. - -P assignment, --pset=assignment
- Set printing options (as with the
\psetcommand). You must separate the name and value with an equal sign, not with a space. For example, to set the output format to LaTeX:-P format=latex. - -q --quiet
- Suppress welcome messages and other informational output (useful when running a command with the
-coption). This option has the same effect as setting the variableQUIETtoon. - -R separator --record-separator=separator
- Use the specified separator between records for unaligned output (
-A). This option has the same effect as the\pset recordsepcommand. - --set=NAME=VALUE
- Set a
ybsqlvariable. See ybsql Properties and Variables. - -s --single-step
- Run in single-step mode, which means that
ybsqlprompts the user before sending each command and provides an option to cancel execution. Use this mode to debug scripts. - -S --single-line
- Run in single-line mode, which means that a newline terminates an SQL command (as a semicolon does). Use this option carefully (for example, when reading commands from files, where a single SQL command may be split into multiple lines).
- -t --tuples-only
- Do not print column names in query results or row counts at the end of the result set. This option has the same effect as the
\tcommand. - -T table_options --table-attr=table_options
- Specify attributes to use within the table tag for HTML output (
-H), such ascellpaddingorbgcolor. - -V, --version
- Print the
ybsqlversion and exit. - -z, --field-separator-zero
- Set the field separator for unaligned output (
-A) to a zero byte. - -x, --expanded
- Use expanded mode for table formatting. This option has the same effect as the
\xcommand. - -X, --no-ybsqlrc
- Do not read the user's startup file (
~/.ybsqlrc), if one exists in the user's home directory. See ybsql Startup File. - -0, --record-separator-zero
- Set the record separator for unaligned output (
-A) to a zero byte. - -1, --single-transaction
- Execute a script in
ybsqlas a single transaction by wrapping the script withBEGINandCOMMITcommands. Either all the commands complete successfully, or no changes are applied. If the script itself usesBEGIN,COMMIT, orROLLBACK, this option will not work. Also, if the script contains any command that cannot be executed inside a transaction block, this option will cause that command (and the whole transaction) to fail.
Parent topic:ybsql Reference