\c (or \connect) [ Dbname [ Username ] ]
\c (or \connect) [ dbname [ username ] ]
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, or other error messages), 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 is a distinction that avoids typos and prevents scripts from accidentally acting on the wrong database.