-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.psqlrc
36 lines (28 loc) · 2 KB
/
.psqlrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
\set AUTOCOMMIT off
\set ON_ERROR_ROLLBACK on
\set ON_ERROR_STOP on
\timing on
-- ✪ Helpful Queries ✪
\set tableswith 'select table_name from information_schema.columns where table_schema = \'public\' and column_name ='
\set columnslike 'select table_name, column_name from information_schema.columns where table_schema = \'public\' and column_name ~'
\set funcs 'SELECT proname FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_proc p ON pronamespace = n.oid WHERE nspname = \'public\';'
\set sourcefor 'SELECT proname, prosrc FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_proc p ON pronamespace = n.oid WHERE nspname = \'public\' and proname ='
\set locks 'select locktype, mode, count(*) as num_locks, count(case when not granted then 1 end) as num_ungranted_locks from pg_locks group by 1, 2 order by 1, 2;'
\set blocks 'select blocking.pid as blocking_pid, statblocking.current_query as blocking_query, statblocking.backend_start as blocking_start, statblocking.client_addr as blocking_ip, blocked.pid as blocked_pid, statblocked.current_query as blocked_query from pg_locks as blocked join public.pg_stat_activity as statblocked on (statblocked.procpid = blocked.pid) left join pg_locks as blocking on (blocked.relation = blocking.relation and blocked.pid != blocking.pid) left join public.pg_stat_activity as statblocking on (statblocking.procpid = blocking.pid) where not blocked.granted;'
-- ✪ Style Config ✪
\pset fieldsep ','
\pset null 'Ø'
\pset linestyle unicode
\pset border 2
\set RED '%[%033[31;1m%]'
\set GREEN '%[%033[32;1m%]'
\set BLUE '%[%033[34;1m%]'
\set YELLOW '%[%033[33;1m%]'
\set WHITE '%[%033[37;1m%]'
\set CLEAR_COLOR '%[%033[0m%]'
\set USER_PROMPT '%n'
\set HOST_PROMPT '%m'
\set DBNAME_PROMPT '%/'
\set TRANSACTION_PROMPT '%x'
\set PROMPT1 :RED :USER_PROMPT :WHITE @ :GREEN :HOST_PROMPT :WHITE : :YELLOW :DBNAME_PROMPT :WHITE '[' :BLUE :TRANSACTION_PROMPT :WHITE '] ➤ ' :CLEAR_COLOR
\set PROMPT2 :WHITE ' ➢ ' :CLEAR_COLOR