-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsqlrc
24 lines (18 loc) · 1.13 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
\set QUIET 1
\set HISTCONTROL ignoredups
\set ON_ERROR_STOP 1
\set ON_ERROR_ROLLBACK interactive
SET client_min_messages = notice;
SET timezone TO 'America/New_York';
\set SHELLHOST `echo $host`
\set PROMPT1 '%[%033[0;35m%]%x%n@%m @%:SHELLHOST::%/%R%#%[%033[0;22m%] '
\set PROMPT2 '%[%033[0;35m%]%x%/%R#%[%033[0;22m%] '
\pset linestyle unicode
\pset null '␀'
-- \pset pager always
\x
\set HISTFILE ~/.psql_history- :DBNAME
\timing
\unset QUIET
\set rtsize '(select table_schema, table_name, pg_relation_size( quote_ident( table_schema ) || \'.\' || quote_ident( table_name ) ) as size, pg_total_relation_size( quote_ident( table_schema ) || \'.\' || quote_ident( table_name ) ) as total_size from information_schema.tables where table_type = \'BASE TABLE\' and table_schema not in (\'information_schema\', \'pg_catalog\') order by pg_relation_size( quote_ident( table_schema ) || \'.\' || quote_ident( table_name ) ) desc, table_schema, table_name)'
\set tsize '(select table_schema, table_name, pg_size_pretty(size) as size, pg_size_pretty(total_size) as total_size from (:rtsize) x order by x.size desc, x.total_size desc, table_schema, table_name)'