Sunday, January 10, 2016

PostgreSQL 9.3 tidbits


Just came across an article that listed some of the cool new features of postgresql database. I've listed out some of those that I liked and thought might be useful...

  • pg_isready - New command-line utility to test whether a server is ready to accept connections.
$ pg_isready -p 5432 -h localhost
localhost:5432 - accepting connections

  • \watch - Allows convenient re-execution of queries. 
postgres=# SELECT datname, query, usename FROM pg_stat_activity ORDER BY query_start DESC LIMIT 1; \watch 60

  • \conninfo - Displays current connection information

postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/tmp" at port "5432".

  • \l - List Databases
postgres=# \l
                                  List of databases
        Name         |  Owner   | Encoding | Collate | Ctype |   Access privileges
---------------------+----------+----------+---------+-------+-----------------------
 arts_v6             | postgres | UTF8     | C       | C     |
 enact_recreate_test | postgres | UTF8     | C       | C     |
 postgres            | postgres | UTF8     | C       | C     |
 quarrysb_13_0_0     | postgres | UTF8     | C       | C     |
 template0           | postgres | UTF8     | C       | C     | =c/postgres          +
                     |          |          |         |       | postgres=CTc/postgres
 template1           | postgres | UTF8     | C       | C     | =c/postgres          +
                     |          |          |         |       | postgres=CTc/postgres
(6 rows)




No comments:

Post a Comment