-
-
Save AdrianTP/3ef8eab3f89926e22f3231660eaeacdf to your computer and use it in GitHub Desktop.
Revisions
-
Kartones revised this gist
Aug 27, 2016 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,9 +17,17 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\dn`: List schemas - `\df`: List functions - `\dv`: List views - `\df+ __function__` : Show function SQL code. - `\x`: Pretty-format query results instead of the not-so-useful ASCII tables User Related: - `\du`: List users - `\du __username__`: List a username if present. - `create role __test1__`: Create a role with an existing username. - `create role __test2__ noinherit login password __passsword__;`: Create a role with username and password. - `set role __test__;`: Change role for current session to `__test__`. - `grant __test2__ to __test1__;`: Allow `__test1__` to set its role as `__test2__`. ## Configuration - Service management commands: -
Kartones revised this gist
Mar 2, 2016 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -105,4 +105,9 @@ Casting: ## Tools - [pg-top](http://ptop.projects.pgfoundry.org/): `top` for PG. `sudo apt-get install ptop` + `pg_top` - [Unix-like reverse search in psql](https://dba.stackexchange.com/questions/63453/is-there-a-psql-equivalent-of-bashs-reverse-search-history): ```bash $ echo "bind "^R" em-inc-search-prev" > $HOME/.editrc $ source $HOME/.editrc ``` -
Kartones revised this gist
Feb 18, 2016 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,8 +35,9 @@ sudo service postgresql restart sudo vim /etc/postgresql/9.3/main/postgresql.conf # Uncomment/Change inside: log_min_messages = debug5 log_min_error_statement = debug5 log_min_duration_statement = -1 sudo service postgresql restart ``` -
Kartones revised this gist
Feb 11, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,8 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\dn`: List schemas - `\df`: List functions - `\dv`: List views - `\df+ __function` : Show function SQL code. - `\x`: Pretty-format query results instead of the not-so-useful ASCII tables ## Configuration -
Kartones revised this gist
Feb 11, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,7 +82,9 @@ ORDER BY - Execution data: - Queries being executed at a certain DB: ```sql SELECT datname, application_name, pid, backend_start, query_start, state_change, state, query FROM pg_stat_activity WHERE datname='__database_name__'; ``` - Get all queries from all dbs waiting for data (might be hung): ```sql -
Kartones revised this gist
Feb 11, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,7 +82,7 @@ ORDER BY - Execution data: - Queries being executed at a certain DB: ```sql SELECT datname, application_name, pid, backend_start, query_start, state_change, state, query FROM pg_stat_activity WHERE datname='__database_name__'; ``` - Get all queries from all dbs waiting for data (might be hung): ```sql -
Kartones revised this gist
Jan 27, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ sudo service postgresql restart ``` - Changing verbosity & querying Postgres log: <br/>1) First edit the config file, set a decent verbosity, save and restart postgres: ``` sudo vim /etc/postgresql/9.3/main/postgresql.conf -
Kartones revised this gist
Jan 27, 2016 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ sudo service postgresql restart ``` - Changing verbosity & querying Postgres log: 1) First edit the config file, set a decent verbosity, save and restart postgres: ``` sudo vim /etc/postgresql/9.3/main/postgresql.conf @@ -39,11 +39,11 @@ log_min_error_statement = debug2 sudo service postgresql restart ``` 2) Now you will get tons of details of every statement, error, and even background tasks like VACUUMs ``` tail -f /var/log/postgresql/postgresql-9.3-main.log ``` 3) How to add user who executed a PG statement to log (editing `postgresql.conf`): ``` log_line_prefix = '%t %u %d %a ' ``` -
Kartones revised this gist
Jan 27, 2016 . 1 changed file with 11 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,8 +21,15 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi ## Configuration - Service management commands: ``` sudo service postgresql stop sudo service postgresql start sudo service postgresql restart ``` - Changing verbosity & querying Postgres log: - First edit the config file, set a decent verbosity, save and restart postgres: ``` sudo vim /etc/postgresql/9.3/main/postgresql.conf @@ -32,11 +39,11 @@ log_min_error_statement = debug2 sudo service postgresql restart ``` - Now you will get tons of details of every statement, error, and even background tasks like VACUUMs ``` tail -f /var/log/postgresql/postgresql-9.3-main.log ``` - How to add user who executed a PG statement to log (editing `postgresql.conf`): ``` log_line_prefix = '%t %u %d %a ' ``` -
Kartones revised this gist
Jan 27, 2016 . 1 changed file with 15 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,38 +51,38 @@ log_line_prefix = '%t %u %d %a ' - `SELECT * FROM pg_indexes WHERE tablename='__table_name__' AND schemaname='__schema_name__';`: Show table indexes - Get all indexes from all tables of a schema: ```sql SELECT t.relname AS table_name, i.relname AS index_name, a.attname AS column_name FROM pg_class t, pg_class i, pg_index ix, pg_attribute a, pg_namespace n WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND a.attnum = ANY(ix.indkey) AND t.relnamespace = n.oid AND n.nspname = 'kartones' ORDER BY t.relname, i.relname ``` - Execution data: - Queries being executed at a certain DB: ```sql SELECT pid, datname, waiting, state, query FROM pg_stat_activity WHERE datname='__database_name__'; ``` - Get all queries from all dbs waiting for data (might be hung): ```sql SELECT * FROM pg_stat_activity WHERE waiting='t' ``` - Currently running queries with process pid: ```sql SELECT pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_activity(s.backendid) AS current_query FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; -
Kartones revised this gist
Jan 27, 2016 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,7 +48,6 @@ log_line_prefix = '%t %u %d %a ' - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use - `show statement_timeout;`: Show current user's statement timeout - `SELECT * FROM pg_indexes WHERE tablename='__table_name__' AND schemaname='__schema_name__';`: Show table indexes - Get all indexes from all tables of a schema: ```sql @@ -73,8 +72,16 @@ order by t.relname, i.relname ``` - Execution data: - Queries being executed at a certain DB: ``` SELECT pid, datname, waiting, state, query FROM pg_stat_activity WHERE datname='__database_name__'; ``` - Get all queries from all dbs waiting for data (might be hung): ``` SELECT * FROM pg_stat_activity WHERE waiting='t' ``` - Currently running queries with process pid: ``` SELECT pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_activity(s.backendid) AS current_query -
Kartones revised this gist
Jan 27, 2016 . 1 changed file with 14 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ ## PSQL Magic words: ```bash psql -U postgres @@ -16,9 +19,7 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\dv`: List views - `\df+ __function` : Show function SQL code. `\x` before pretty-formats it ## Configuration Changing verbosity & querying Postgres log: - First edit the config file, set a decent verbosity, save and restart postgres: @@ -41,7 +42,7 @@ log_line_prefix = '%t %u %d %a ' ``` ## Handy queries - `SELECT * FROM pg_proc WHERE proname='__procedurename__'`: List procedure/function - `SELECT * FROM pg_views WHERE viewname='__viewname__';`: List view (including the definition) - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use @@ -78,4 +79,12 @@ order by SELECT pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_activity(s.backendid) AS current_query FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; ``` Casting: - `CAST (column AS type)` or `column::type` - `'__table_name__'::regclass::oid`: Get oid having a table name ## Tools - [pg-top](http://ptop.projects.pgfoundry.org/): `top` for PG. `sudo apt-get install ptop` + `pg_top` -
Kartones revised this gist
Oct 23, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,6 +75,7 @@ order by - `select * from pg_stat_activity where waiting='t'`: Get all queries waiting for data (that might be hung) - Get all currently executing queries: ``` SELECT pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_activity(s.backendid) AS current_query FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; ``` -
Kartones revised this gist
Oct 23, 2015 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -72,4 +72,9 @@ order by t.relname, i.relname ``` - `select * from pg_stat_activity where waiting='t'`: Get all queries waiting for data (that might be hung) - Get all currently executing queries: ``` SELECT pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_activity(s.backendid) AS current_query FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; ``` -
Kartones revised this gist
Oct 23, 2015 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,6 +35,11 @@ sudo service postgresql restart ``` tail -f /var/log/postgresql/postgresql-9.3-main.log ``` - How to add user who executed a PG statement to log (editing `postgresql.conf`): ``` log_line_prefix = '%t %u %d %a ' ``` SQL queries: - `SELECT * FROM pg_proc WHERE proname='__procedurename__'`: List procedure/function -
Kartones revised this gist
Oct 23, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,4 +66,5 @@ where order by t.relname, i.relname ``` - `select * from pg_stat_activity where waiting='t'`: Get all queries waiting for data (that might be hung) -
Kartones revised this gist
Oct 19, 2015 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,22 @@ Casting: - `CAST (column AS type)` or `column::type` - `'__table_name__'::regclass::oid`: Get oid having a table name Changing verbosity & querying Postgres log: - First edit the config file, set a decent verbosity, save and restart postgres: ``` sudo vim /etc/postgresql/9.3/main/postgresql.conf # Uncomment/Change inside: log_min_messages = debug2 log_min_error_statement = debug2 sudo service postgresql restart ``` - Now you will get tons of details of every statement, error, and even background tasks like VACUUMs ``` tail -f /var/log/postgresql/postgresql-9.3-main.log ``` SQL queries: - `SELECT * FROM pg_proc WHERE proname='__procedurename__'`: List procedure/function - `SELECT * FROM pg_views WHERE viewname='__viewname__';`: List view (including the definition) -
Kartones revised this gist
Sep 7, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ Magic words: ```bash psql -U postgres ``` If run with `-E` flag, it will describe the underlaying queries of the `\` commands (cool for learning!). Most `\d` commands support additional param of `__schema__.name__` and accept wildcards like `*.*` -
Kartones revised this gist
Jul 14, 2015 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,18 +14,19 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\df`: List functions - `\dv`: List views - `\df+ __function` : Show function SQL code. `\x` before pretty-formats it Casting: - `CAST (column AS type)` or `column::type` - `'__table_name__'::regclass::oid`: Get oid having a table name SQL queries: - `SELECT * FROM pg_proc WHERE proname='__procedurename__'`: List procedure/function - `SELECT * FROM pg_views WHERE viewname='__viewname__';`: List view (including the definition) - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use - `show statement_timeout;`: Show current user's statement timeout - `SELECT pid, datname, waiting, state, query FROM pg_stat_activity WHERE datname='__database_name__';`: Show queries being executed at a certain DB. Can also display query time, etc. - `SELECT * FROM pg_indexes WHERE tablename='__table_name__' AND schemaname='__schema_name__';`: Show table indexes - Get all indexes from all tables of a schema: ```sql select -
Kartones revised this gist
Jul 14, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use - `show statement_timeout;`: Show current user's statement timeout - `SELECT pid, datname, waiting, state, query FROM pg_stat_activity WHERE datname='__database_name__';`: Show queries being executed at a certain DB. Can also display query time, etc. - `SELECT * FROM pg_indexes WHERE tablename='__table_name__' AND schemaname='__schema_name__';`: Show table indexes Casting: - `CAST (column AS type)` or `column::type` -
Kartones revised this gist
Jul 14, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ Casting: - `CAST (column AS type)` or `column::type` SQL queries: - Get all indexes from all tables of a schema: ```sql select t.relname as table_name, -
Kartones revised this gist
Jul 14, 2015 . 1 changed file with 25 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,3 +24,28 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi Casting: - `CAST (column AS type)` or `column::type` SQL queries: - Get all indexes from all tables of a scheam: ```sql select t.relname as table_name, i.relname as index_name, a.attname as column_name from pg_class t, pg_class i, pg_index ix, pg_attribute a, pg_namespace n where t.oid = ix.indrelid and i.oid = ix.indexrelid and a.attrelid = t.oid and a.attnum = ANY(ix.indkey) and t.relnamespace = n.oid and n.nspname = 'kartones' order by t.relname, i.relname ``` -
Kartones revised this gist
Jul 14, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use - `show statement_timeout;`: Show current user's statement timeout - `SELECT pid, datname, waiting, state, query FROM pg_stat_activity WHERE datname='__database_name__';`: Show queries being executed at a certain DB. Can also display query time, etc. - `SELECT * FROM pg_indexes WHERE tablename='__table_name__';`: Show table indexes Casting: - `CAST (column AS type)` or `column::type` -
Kartones revised this gist
May 29, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use - `show statement_timeout;`: Show current user's statement timeout - `SELECT pid, datname, waiting, state, query FROM pg_stat_activity WHERE datname='__database_name__';`: Show queries being executed at a certain DB. Can also display query time, etc. Casting: - `CAST (column AS type)` or `column::type` -
Kartones revised this gist
Apr 14, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `SELECT * FROM pg_views WHERE viewname='__viewname__';`: List view (including the definition) - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use - `show statement_timeout;`: Show current user's statement timeout Casting: - `CAST (column AS type)` or `column::type` -
Kartones revised this gist
Sep 1, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,3 +18,6 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `SELECT * FROM pg_views WHERE viewname='__viewname__';`: List view (including the definition) - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use Casting: - `CAST (column AS type)` or `column::type` -
Kartones revised this gist
Aug 12, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\q`: Quit/Exit - `\c __database__`: Connect to a database - `\d __table__`: Show table definition including triggers - `\dt *.*`: List tables from all schemas (if `*.*` is omitted will only show SEARCH_PATH ones) - `\l`: List databases - `\dn`: List schemas - `\df`: List functions -
Kartones revised this gist
Aug 11, 2014 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,12 +7,14 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\q`: Quit/Exit - `\c __database__`: Connect to a database - `\d __table__`: Show table definition including triggers - `\dt`: List tables - `\l`: List databases - `\dn`: List schemas - `\df`: List functions - `\dv`: List views - `\df+ __function` : Show function SQL code. `\x` before pretty-formats it - `SELECT * FROM pg_proc WHERE proname='__procedurename__'`: List procedure/function - `SELECT * FROM pg_views WHERE viewname='__viewname__';`: List view (including the definition) - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use -
Kartones revised this gist
Jun 2, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,3 +14,5 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\dv`: List views - `SELECT * FROM pg_proc WHERE proname='__procedurename__'`: List procedure/function - `SELECT * FROM pg_views WHERE viewname='__viewname__';`: List view (including the definition) - `SELECT pg_size_pretty(pg_total_relation_size('__table_name__'));`: Show DB table space in use. - `SELECT pg_size_pretty(pg_database_size('__database_name__'));`: Show DB space in use. -
Kartones revised this gist
Jun 2, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Most `\d` commands support additional param of `__schema__.name__` and accept wi - `\c __database__`: Connect to a database - `\dt`: List tables - `\l`: List databases - `\dn`: List schemas - `\df`: List functions - `\dv`: List views - `SELECT * FROM pg_proc WHERE proname='__procedurename__'`: List procedure/function
NewerOlder