33.14. 環境變數
版本:11
以下環境變數可用於選擇預設連線參數值,如果呼叫變數沒有直接指定值, PQconnectdb,PQsetdbLogin 和 PQsetdb 將使用這些值。例如,這些有助於避免將資料庫連線訊息硬寫到簡單的用戶端應用程序中。
PGHOST的行為與 host 參數相同。PGHOSTADDR的行為與 hostaddr 連線參數相同。這可以代替 PGHOST 或者除了 PGHOST 之外設定,以避免 DNS 查詢的開銷。PGPORT的行為與 port 連線參數相同。PGDATABASE的行為與 dbname 連線參數相同。PGUSER的行為與 user 連線參數相同。PGPASSFILE行為與 passfile 連線參數相同。PGSERVICEbehaves the same as the service connection parameter.PGSERVICEFILEspecifies the name of the per-user connection service file. If not set, it defaults to~/.pg_service.conf(see Section 33.16).PGOPTIONSbehaves the same as the options connection parameter.PGAPPNAMEbehaves the same as the application_name connection parameter.PGSSLMODEbehaves the same as the sslmode connection parameter.PGREQUIRESSLbehaves the same as the requiressl connection parameter. This environment variable is deprecated in favor of thePGSSLMODEvariable; setting both variables suppresses the effect of this one.PGSSLCOMPRESSIONbehaves the same as the sslcompression connection parameter.PGSSLCERTbehaves the same as the sslcert connection parameter.PGSSLKEYbehaves the same as the sslkey connection parameter.PGSSLROOTCERTbehaves the same as the sslrootcert connection parameter.PGSSLCRLbehaves the same as the sslcrl connection parameter.PGREQUIREPEERbehaves the same as the requirepeer connection parameter.PGKRBSRVNAMEbehaves the same as the krbsrvname connection parameter.PGGSSLIBbehaves the same as the gsslib connection parameter.PGCONNECT_TIMEOUTbehaves the same as the connect_timeout connection parameter.PGCLIENTENCODINGbehaves the same as the client_encoding connection parameter.PGTARGETSESSIONATTRSbehaves the same as the target_session_attrs connection parameter.
以下環境變數可用於指定每個 PostgreSQL 連線的預設行為。(有關基於每個使用者或每個資料庫設定預設行為的方法,另請參閱 ALTER ROLE 和 ALTER DATABASE 指令。)
PGDATESTYLE設定日期/時間表示的預設樣式。 (相當於 SET datestyle TO ....)PGTZ設定預設時區。 (相當於SET timezone TO ....)PGGEQO設定 genetic 查詢最佳化程序的預設模式。(相當於SET geqo TO ....)
有關這些環境變數的正確值的資訊,請參閱 SQL 指令 SET。
以下環境變數決定了 libpq 的內部行為;它們會覆寫編譯時的預設值。
PGSYSCONFDIR設定包含 pg_service.conf 檔案的目錄,在未來版本中可能用於設定其他系統範圍的組態檔案。PGLOCALEDIR設定包含用於訊息本地化的區域設定檔案的目錄。
Last updated
Was this helpful?