-u user The -u (user) option causes sudo to run the specified command as a user other than root. To
specify a uid instead of a user name, use #uid. When running commands as a uid, many shells
require that the '#' be escaped with a backslash ('\'). Security policies may restrict uids
to those listed in the password database. The sudoers policy allows uids that are not in the
password database as long as the targetpw option is not set. Other security policies may not
support this.
|
-c command
--command command
Specifies that psql is to execute one command string, command, and then exit. This is useful in
shell scripts.
command must be either a command string that is completely parsable by the server (i.e., it
contains no psql specific features), or a single backslash command. Thus you cannot mix SQL and
psql meta-commands with this option. To achieve that, you could pipe the string into psql, like
this: echo '\x \\ SELECT * FROM foo;' | psql. (\\ is the separator meta-command.)
If the command string contains multiple SQL commands, they are processed in a single transaction,
unless there are explicit BEGIN/COMMIT commands included in the string to divide it into multiple
transactions. This is different from the behavior when the same string is fed to psql's standard
input.
|
psql [ option... ] [ dbname
[ username ] ]
-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.
If this parameter contains an = sign, it is treated as a conninfo string. See in the documentation
for more information.
-U username
--username username
Connect to the database as the user username instead of the default. (You must have permission to
do so, of course.)
|