DATABASE » SQL » POSTGRESQL

Command

Usage

shell
psql OPTIONS DBNAME
Connection optionDescription
-d --dbnameSpecifies the name of the database to connect to.
-h --hostConnect to the PostgreSQL server on the given host.
-p --portThe TCP/IP port number to use for the connection.
-U --usernameThe PostgreSQL user name to use when connecting to the server.
-w --no-passwordNever prompt for password.
-W --passwordForce password prompt.
OptionDescription
-c --commandExecute the given SQL query and exit.

You may provide the password by prepending PGPASSWORD to the command.

shell
env PGPASSWORD=password psql dbname