Postgresql (psql) .psqlrc技巧和窍门

Postgresql (psql) .psqlrc技巧和窍门,第1张

概述Set all null fields to NULL: \pset null 'NULL' After this, the query results look like this: select 'test' as test_text, null as test_null; test_text | test_null-----------+----------- test      | Set all null fIElds to NulL:
\pset null 'NulL'

After this,the query results look like this:

select 'test' as test_text,null as test_null; test_text | test_null-----------+----------- test| NulL(1 row)

Set the command history file names for each host and database: \set HISTfile ~/.psql_history- :HOST - :DBname

After this,the history file naming look like this:

.psql_history-Alpha-testdb.psql_history-localhost-test.psql_history-10.20.10.101-production...

Set the number of commands to store in the command history:

\set HISTSIZE 2000

Set timing on and see how long query took:

\timing

psql prompt can be customized to your preference:

\set PROMPT1 '(%n@%M:%>) [%/] > '\set PROMPT2 ''

After this,the PROMPT1 look like this:

(wwwuser@Alpha:5432) [webdb] > 

And PROMPT2 is empty.
Complete information can be found here,under prompting.

Set clIEnt enCoding: \enCoding unicode

Final .psqlrc file look like this:

'NulL'\set HISTfile ~/.psql_history- :HOST - :DBname\set HISTSIZE 2000\timing\set PROMPT1 ''\enCoding unicode

One additional tip is to add less to PAGER environment variable if you want to use less rather than more. So simply add following row to profile (/etc/profile or ~/.profile):

export PAGER=less 总结

以上是内存溢出为你收集整理的Postgresql (psql) .psqlrc技巧窍门全部内容,希望文章能够帮你解决Postgresql (psql) .psqlrc技巧和窍门所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1179655.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存