33.14. 環境變數
版本:11
Was this helpful?
版本:11
Was this helpful?
以下環境變數可用於選擇預設連線參數值,如果呼叫變數沒有直接指定值, PQconnectdb,PQsetdbLogin 和 PQsetdb 將使用這些值。例如,這些有助於避免將資料庫連線訊息硬寫到簡單的用戶端應用程序中。
PGHOST
的行為與 參數相同。
PGHOSTADDR
的行為與 連線參數相同。這可以代替 PGHOST 或者除了 PGHOST 之外設定,以避免 DNS 查詢的開銷。
PGPORT
的行為與 連線參數相同。
PGDATABASE
的行為與 連線參數相同。
PGUSER
的行為與 連線參數相同。
PGPASSWORD
的行為與 連線參數相同。但由於安全因素,不建議使用此環境變數,因為某些作業系統允許非 root 使用者透過 ps 查看程序環境變數;而是考慮使用密碼檔案(參閱)。
PGPASSFILE
行為與 連線參數相同。
PGSERVICE
behaves the same as the connection parameter.
PGSERVICEFILE
specifies the name of the per-user connection service file. If not set, it defaults to ~/.pg_service.conf
(see ).
PGOPTIONS
behaves the same as the connection parameter.
PGAPPNAME
behaves the same as the connection parameter.
PGSSLMODE
behaves the same as the connection parameter.
PGREQUIRESSL
behaves the same as the connection parameter. This environment variable is deprecated in favor of the PGSSLMODE
variable; setting both variables suppresses the effect of this one.
PGSSLCOMPRESSION
behaves the same as the connection parameter.
PGSSLCERT
behaves the same as the connection parameter.
PGSSLKEY
behaves the same as the connection parameter.
PGSSLROOTCERT
behaves the same as the connection parameter.
PGSSLCRL
behaves the same as the connection parameter.
PGREQUIREPEER
behaves the same as the connection parameter.
PGKRBSRVNAME
behaves the same as the connection parameter.
PGGSSLIB
behaves the same as the connection parameter.
PGCONNECT_TIMEOUT
behaves the same as the connection parameter.
PGCLIENTENCODING
behaves the same as the connection parameter.
PGTARGETSESSIONATTRS
behaves the same as the connection parameter.
PGDATESTYLE
設定日期/時間表示的預設樣式。 (相當於 SET datestyle TO ....)
PGTZ
設定預設時區。 (相當於 SET timezone TO ....
)
PGGEQO
設定 genetic 查詢最佳化程序的預設模式。(相當於 SET geqo TO ....
)
以下環境變數決定了 libpq 的內部行為;它們會覆寫編譯時的預設值。
PGSYSCONFDIR
設定包含 pg_service.conf 檔案的目錄,在未來版本中可能用於設定其他系統範圍的組態檔案。
PGLOCALEDIR
設定包含用於訊息本地化的區域設定檔案的目錄。
以下環境變數可用於指定每個 PostgreSQL 連線的預設行為。(有關基於每個使用者或每個資料庫設定預設行為的方法,另請參閱 和 指令。)
有關這些環境變數的正確值的資訊,請參閱 SQL 指令 。