-a --echo-all
Prints all input lines to standard output as they are read. This is more useful for script processing than interactive mode. It is equivalent to setting the variable ECHO
to all
.
-A --no-align
Switches to unaligned output mode. (The default output mode is aligned.)
-c command --command command
Executes one command and exits. This is useful in shell scripts. The command must be either a command string that is completely parsable by the server (i.e., it contains no vsql specific features), or a single meta-command. In other words, you cannot mix SQL and vsql meta-commands. To achieve that, you can pipe the string into vsql like this: echo "\ x \\ select * from foo;" | vsql.
-d dbname --dbname dbname
Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line.
-e --echo-queries
Copies all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable ECHO
to queries
.
-f filename --file filename
Uses the file filename as the source of commands instead of reading commands interactively. After the file is processed, vsql terminates. This is in many ways equivalent to the internal command
\i
.
Reads input from the file filename and executes it as though it had been typed on the keyboard.
Note: To see the lines on the screen as they are read, set the variable ECHO to all.
If filename is -
(hyphen), the standard input is read.
Using this option is subtly different from writing vsql
<
filename. In general, both will do what you expect, but using -f
enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output that you would have gotten had you entered everything by hand.
-F separator --field-separator separator
Specifies the field separator. This is equivalent to \pset
fieldsep
or
\f
.
Sets the field separator for unaligned query output. The default is the vertical bar (|
). See also \pset
for a generic way of setting output options.
-h hostname --host hostname
Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the socket.
-H --html
Turn on HTML tabular output. This is equivalent to \pset
format html
or the
\H
command.
Toggles HTML query output format. This command is for compatibility and convenience, but see \pset
about setting other output options.
-o filename --output filename
Writes all query output into file filename. This is equivalent to the command \o
.
-p port --port port
Specifies the TCP port or the local socket file extension on which the server is listening for connections. Defaults to port 5433.
-P assignment --pset assignment
Allows you to specify printing options in the style of \pset
on the command line. Note that you have to separate name and value with an equal sign instead of a space. Thus to set the output format to LaTeX, you could write -P format=latex
.
-q --quiet
Specifies that vsql should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this appears. This is useful with the -c
option. Within vsql you can also set the QUIET
variable to achieve the same effect.
-R separator --record-separator separator
Use separator as the record separator. This is equivalent to the \pset
recordsep
command.
-s --single-step
Run in single-step mode for debugging scripts. Forces vsql to prompt before each statement is sent to the database and allows you to cancel execution.
-S --single-line
Runs in single-line mode where a newline terminates an SQL command, as a semicolon does.
Note: This mode is provided for those who insist on it, but you are not necessarily encouraged to use it. In particular, if you mix SQL and meta-commands on a line the order of execution might not always be clear to the inexperienced user.
-t --tuples-only
Disables printing of column names and result row count footers, etc. This is equivalent to the
\t
command.
Toggles the display of output column name headings and row count footer. This command is equivalent to \pset
tuples_only
and is provided for convenience.
-T table_options --table-attr table_options
Allows you to specify options to be placed within the HTML table
tag. See \pset
for details.
-U username --username username
Connects to the database as the user username instead of the default.
-v assignment --set assignment --variable assignment
Perform a variable assignment, like the
\set
internal command. You must separate name and value, if any, by an equal sign on the command line.
Sets the internal variable name to value or, if more than one value is given, to the concatenation of all of them. If no second argument is given, the variable is set with no value. To unset a variable, use the \ unset
command.
Valid variable names can contain characters, digits, and underscores. See the section Variables below for details. Variable names are case-sensitive.
Note: vsql treats several variables as special. They are documented in Variables.
To unset a variable, omit the equal sign. To set a variable without a value, use the equal sign but omit the value. These assignments are done during a very early stage of start-up, so variables reserved for internal purposes can get overwritten later.
-V --version
Print the vsql version and exit.
-w password
Specifies the password for a database user.
Using this command line option displays the database password in plain text on the screen. Use it with care particularly if you are connecting as the Database Administrator.
-W --password
Forces vsql to prompt for a password before connecting to a database. The password is not displayed on the screen. This option remains set for the entire session, even if you change the database connection with the meta-command
\connect
.
Establishes a connection to a new database and/or under a user name. The previous connection is closed. If dbname is - the current database name is assumed.
If username is omitted the current user name is assumed.
As a special rule, \connect without any arguments connects to the default database as the default user (as you would have gotten by starting vsql without any arguments).
If the connection attempt fails (wrong user name, access denied, etc.), the previous connection is kept if and only if vsql is in interactive mode. When executing a non-interactive script, processing immediately stops with an error. This distinction that avoids typos and a prevent scripts from accidentally acting on the wrong database.
-x --expanded
Enables extended table formatting mode. This is equivalent to the command
\ x
.
Toggles extended table formatting mode. As such it is equivalent to \pset
expanded
.
There is no space between the backslash and the x.
-X, --no-vsqlrc
Prevents the start-up file from being read (the system-wide vsqlrc
file or the user's ~/.vsqlrc
file).
-? --help
Displays help about vsql command line arguments and exits.