You can use the following environment variables to select default connection parameter values, which are used by PQconnectdb or PQsetdbLogin if no value is directly specified by the calling code. These are useful to avoid hard-coding database names into simple application programs.
PGHOST sets the default server name. If this begins with a slash, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored (default "/tmp").
PGPORT sets the default TCP port number or Unix-domain socket file extension for communicating with the Red Hat Database backend.
PGDATABASE sets the default Red Hat Database database name.
PGUSER sets the username used to connect to the database and for authentication.
PGPASSWORD sets the password used if the backend demands password authentication.
PGREALM sets the Kerberos realm to use with Red Hat Database, if it is different from the local realm. If PGREALM is set, Red Hat Database applications will attempt authentication with servers for this realm and use separate ticket files to avoid conflicts with local ticket files. This environment variable is used only if Kerberos authentication is selected by the backend.
PGOPTIONS sets additional runtime options for the Red Hat Database backend.
PGTTY sets the file or tty on which debugging messages from the backend server are displayed.
You can use the following environment variables to specify user-level default behavior for every Red Hat Database session:
PGDATESTYLE sets the default style of date/time representation.
PGTZ sets the default time zone.
PGCLIENTENCODING sets the default client encoding (if MULTIBYTE support was selected when configuring Red Hat Database).
You can use the following environment variables to specify default internal behavior for every Red Hat Database session:
PGGEQO sets the default mode for the genetic optimizer.
Refer to the SQL SET command in the Red Hat Database SQL Guide and Reference for information on correct values for these environment variables.