PostgreSQL11自定義帶日期等個性化配置的登入提示符

chenfeng發表於2021-02-25

在centos7上編輯/root/.psqlrc檔案,

# vi /root/.psqlrc

新增如下內容:

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

\set PROMPT2 '%M %n@%/%R %# '

\set PROMPT3 '%M %n@%/%R %# '

\timing

\set QUIET 1

\pset null '[null]'

\set COMP_KEYWORD_CASE upper

\set HISTSIZE 2000

\set VERBOSITY verbose

\set QUIET 0

\echo 'Welcome to PostgreSQL! \n'

\echo 'Type \\c to change database. \n'

\echo 'Type \\q to exit. \n'


測試:

# psql -h 127.0.0.1 -U postgres -p 5432 -d test

Timing is on.

Welcome to PostgreSQL! 


Type \c to change database. 


Type \q to exit. 


psql (11.3)

Type "help" for help.


10:54:52 (postgres@127.0.0.1:5432)test=# 

10:55:11 (postgres@127.0.0.1:5432)test=# 

10:55:11 (postgres@127.0.0.1:5432)test=# 

10:55:11 (postgres@127.0.0.1:5432)test=# 

10:55:11 (postgres@127.0.0.1:5432)test=# 

10:55:11 (postgres@127.0.0.1:5432)test=# 

10:55:11 (postgres@127.0.0.1:5432)test=# \q



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2759241/,如需轉載,請註明出處,否則將追究法律責任。

相關文章