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 ECHO variable to all.
-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 ECHO variable to errors.
-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 ybsql or 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 explicit BEGIN/COMMIT commands).
-e, --echo-queries
Copy all SQL commands to standard output. This option has the same effect as setting the ECHO variable to queries.
-f filename, --file=filename
Read commands from a named file instead of interactively, then exit (similar to using the \i command). If the specified file is - (a hyphen), ybsql reads from standard input until an EOF or a \q command 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 fieldsep or \f.
-H, --html
Return HTML tabular output. This option has the same effect as \pset format html or \H.
--help
Return a summary of the ybsql command-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 \o command.
-P assignment, --pset=assignment
Set printing options (as with the \pset command). 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 -c option). This option has the same effect as setting the variable QUIET to on.
-R separator --record-separator=separator
Use the specified separator between records for unaligned output (-A). This option has the same effect as the \pset recordsep command.
--set=NAME=VALUE
Set a ybsql variable. See ybsql Variables.
-s --single-step
Run in single-step mode, which means that ybsql prompts 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 \t command.
-T table_options --table-attr=table_options
Specify attributes to use within the table tag for HTML output (-H), such as cellpadding or bgcolor.
-V, --version
Print the ybsql version 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 \x command.
-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 ybsql as a single transaction by wrapping the script with BEGIN and COMMIT commands. Either all the commands complete successfully, or no changes are applied. If the script itself uses BEGIN, COMMIT, or ROLLBACK, 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.