
↓ 変数
> psql -U postgres -p 5952 psql (9.5.3, サーバー 9.5.2) "help" でヘルプを表示します. postgres=# \set AUTOCOMMIT = 'on' PROMPT1 = '%/%R%# ' PROMPT2 = '%/%R%# ' PROMPT3 = '>> ' VERBOSITY = 'default' VERSION = 'PostgreSQL 9.5.3, compiled by Visual C++ build 1800, 64-bit' DBNAME = 'postgres' USER = 'postgres' HOST = 'localhost' PORT = '5952' ENCODING = 'SJIS' postgres=# select version(); version -------------------------------------------------------------------------------- PostgreSQL 9.5.2 on x86_64-unknown-cygwin, compiled by gcc (GCC) 5.3.0, 64-bit (1 行)

psql
»
↓ 実行ファイルをバイナリエディタ(Stirling)で開くと、確かに


本題。1
今回は
-- r:\.psqlrc \set cver :VERSION \unset VERSION select version() as sver \gset
まず既存の変数
↓ 結果の確認。一時的に環境変数
-- on Command Prompt > set PSQLRC=r:\.psqlrc > psql ... psql (9.5.3, サーバー 9.5.2) "help" でヘルプを表示します. postgres=# \set AUTOCOMMIT = 'on' PROMPT1 = '%/%R%# ' PROMPT2 = '%/%R%# ' PROMPT3 = '>> ' VERBOSITY = 'default' DBNAME = 'postgres' USER = 'postgres' HOST = 'localhost' PORT = '5952' ENCODING = 'SJIS' cver = 'PostgreSQL 9.5.3, compiled by Visual C++ build 1800, 64-bit' sver = 'PostgreSQL 9.5.2 on x86_64-unknown-cygwin, compiled by gcc (GCC) 5.3.0, 64-bit'

変数の中身は「\echo :