PostGreSQL Session Management

Command Line Interface

Connect

Connect to the PostGreSQL ORDBMS via the psql binary, specifying host tethys:


% psql -h tethys
Password: 
psql (8.4.10)
Type "help" for help.

cwmiller=>

Show Databases

List databases that you have permission to see.


cwmiller=> \l
                            List of databases
   Name    |  Owner   | Encoding | Collation | Ctype | Access privileges 
-----------+----------+----------+-----------+-------+-------------------
 cwmiller  | cwmiller | UTF8     | C         | C     | 
 mydb      | cwmiller | UTF8     | C         | C     | 
 postgres  | pgsql    | UTF8     | C         | C     | 
 template0 | pgsql    | UTF8     | C         | C     | =c/pgsql
                                                     : pgsql=CTc/pgsql
 template1 | pgsql    | UTF8     | C         | C     | =c/pgsql
                                                     : pgsql=CTc/pgsql
 zoo       | pgsql    | UTF8     | C         | C     | 
(6 rows)


Connect to a Database


cwmiller=> \c mydb

Show Tables within the Selected Database


mydb=> \d
No relations found.

Change Your Password

When you get your new account, change your default password to a password only you know.


cwmiller=> alter user cwmiller with password 'MyNewPassword123';
ALTER ROLE

Quit


mydb=> \q