-
Notifications
You must be signed in to change notification settings - Fork 0
/
.psqlrc
51 lines (45 loc) · 2.44 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
\set QUIET 1
--------------------------------------------------------------------------------
-- Aliases
--------------------------------------------------------------------------------
\set clear '\\! clear;'
\set conn_info 'SELECT usename, count(*) FROM pg_stat_activity GROUP BY usename;'
\set database_size 'SELECT datname, pg_size_pretty(pg_database_size(datname)) db_size FROM pg_database ORDER BY db_size;'
\set extensions 'SELECT * FROM pg_available_extensions;'
\set settings 'SELECT name, setting, unit, context FROM pg_settings;'
\set sp 'SHOW search_path;'
\set table_size 'SELECT nspname || \'.\' || relname AS \"relation\", pg_size_pretty(pg_relation_size(C.oid)) AS "size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN (\'pg_catalog\', \'information_schema\') ORDER BY pg_relation_size(C.oid) DESC LIMIT 40;'
\set uptime 'SELECT now() - pg_postmaster_start_time() AS uptime;'
\set version 'SELECT version();'
--------------------------------------------------------------------------------
-- Echo
--------------------------------------------------------------------------------
\echo 'Current Host Server Data Time: '`date`'\n'
\echo '\t\t:clear\t\t-- Clear screen'
\echo '\t\t:conn_info\t-- Server connections'
\echo '\t\t:database_size\t-- Database size'
\echo '\t\t:extensions\t-- Server extensions'
\echo '\t\t:settings\t-- Server settings'
\echo '\t\t:sp\t\t-- Display search path'
\echo '\t\t:table_size\t-- Table size'
\echo '\t\t:uptime\t\t-- Server uptime'
\echo '\t\t:version\t-- Display current Postgres version'
--------------------------------------------------------------------------------
-- Formatting and Verbosity
--------------------------------------------------------------------------------
\x auto
\pset null 'NULL'
\set COMP_KEYWORD_CASE upper
\set HISTCONTROL ignoredups
\set HISTFILE ~/.psql_history- :HOST - :DBNAME
\set VERBOSITY verbose
--------------------------------------------------------------------------------
-- Prompt
--------------------------------------------------------------------------------
\set PROMPT1 '%M:%> %n@%/%R%#%x '
\set PROMPT2 '%M %n@%/%R %# '
--------------------------------------------------------------------------------
-- Timing
--------------------------------------------------------------------------------
\timing
\set QUIET 0