这篇文章主要讲解了“怎么掌握PostgreSQL的tips”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么掌握PostgreSQL的tips”吧!

下面是一些有用的tips:

In psql, tag your queries and use Ctrl+R

[local]:5432pg12@testdb=#select*fromt1limit1;id|c1|c2----+----+----4|4|4(1row)Time:1.872ms[local]:5432pg12@testdb=#select*fromtestlimit1;ERROR:relation"test"doesnotexistLINE1:select*fromtestlimit1;^Time:0.996ms[local]:5432pg12@testdb=#createtabletest(idint);CREATETABLETime:6.019ms[local]:5432pg12@testdb=#insertintotestvalues(1);INSERT01Time:2.310ms[local]:5432pg12@testdb=#insertintotestvalues(2);INSERT01Time:2.409ms

这时候使用快捷键Ctrl + R,显示搜索框,输入t1,psql检索t1相关的sql并显示在界面上.

(reverse-i-search)`':(reverse-i-search)`t1':select*fromt1limit1;

Better psql output
\x不够强大,可使用pspg.

Get a stack trace for an error
使用gdb在errfinish上设置断点可跟踪错误

[local]:5432pg12@testdb=#SELECTpg_backend_pid();pg_backend_pid----------------1538(1row)...(gdb)berrfinishBreakpoint1at0xa65517:fileelog.c,line412.(gdb)cContinuing.

如出现执行错误,会在gdb中停止,利用bt可打印调用栈

感谢各位的阅读,以上就是“怎么掌握PostgreSQL的tips”的内容了,经过本文的学习后,相信大家对怎么掌握PostgreSQL的tips这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!