Connecting to PostgresSQL database
After logging into postgres user, from cmdline type psql.
bash-4.1$ psql
could not change directory to "/var/lib/mysql/TESTDB"
psql (8.4.18)
Type "help" for help.
Some basic cmds:
postgres=# show databases; -- This list databases
postgres=# List databases -- This list databases
-- Listing database in postgres
## \l will give you basic information of databases in instance
postgres-# \l
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
(3 rows)
\l+ will give you advanced information of databases in instance. Including Access privileges,size,tablespace.. etc
postgres=# \l+
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges | Size | Tablespace |
Description
-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+---
------------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 5510 kB | pg_default |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres | 5408 kB | pg_default |
: postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres | 5408 kB | pg_default | de
fault template database
: postgres=CTc/postgres
(3 rows)
postgres=# \l
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
(3 rows)
Comments
Post a Comment