PostgreSQL 定制psql提示符

通过配置.psqlrc文件(linux平台)可定制psql提示符.

.psqlrc文件
cd
vim .psqlrc


\set PROMPT1 '%`date +%H:%M:%S` (%n@%M:%>)%/%R%#%x '
\set PROMPT2 '%M %n@%/%R%# '

样例


[xdb@localhost ~]$ psql -d testdb
psql (11.1)
Type "help" for help.
11:17:02 (xdb@[local]:5432)testdb=# select
[local] xdb@testdb-# txid_current();
 txid_current 
--------------
         2316
(1 row)
11:17:19 (xdb@[local]:5432)testdb=#

参考资料
How To Customize the PostgreSQL Prompt with psqlrc on Ubuntu 14.04

请使用浏览器的分享功能分享到微信等