psql Example


Transcript of PostgreSQL Session

The following is a transcript of a PostgreSQL session using psql to connect to a server running on cs.georgefox.edu server:
% psql -U dhansen -h cs.georgefox.edu company
Password:

Welcome to the POSTGRESQL interactive sql monitor:
  Please read the file COPYRIGHT for copyright terms of POSTGRESQL

   type \? for help on slash commands
   type \q to quit
   type \g or terminate with semicolon to execute query
 You are currently connected to the database: company

company=> \d

Database    = company
 +------------------+----------------------------------+----------+
 |  Owner           |             Relation             |   Type   |
 +------------------+----------------------------------+----------+
 | dhansen          | department                       | table    |
 | dhansen          | department_pkey                  | index    |
 | dhansen          | dependent                        | table    |
 | dhansen          | dependent_pkey                   | index    |
 | dhansen          | dept_locations                   | table    |
 | dhansen          | dept_locations_pkey              | index    |
 | dhansen          | employee                         | table    |
 | dhansen          | employee_pkey                    | index    |
 | dhansen          | project                          | table    |
 | dhansen          | project_pkey                     | index    |
 | dhansen          | works_on                         | table    |
 | dhansen          | works_on_pkey                    | index    |
 +------------------+----------------------------------+----------+
company=> select fname, salary from employee;

fname   |  salary
--------+--------
John    |30000.00
Franklin|40000.00
Alica   |25000.00
Jennifer|43000.00
Ramish  |38000.00
Joyce   |25000.00
Ahmad   |25000.00
James   |55000.00
(8 rows)

company=> select max(salary) from employee;

     max
--------
55000.00
(1 row)

company=> \q
%

Capturing Output

The output of this PostgreSQL session was captured using the UNIX script command. See the UNIX man pages for more information on how to use script to capture your sessions, you may want to use this mechanism for turning in homework assignments that involve using PostgreSQL.


Last modified: , by David M. Hansen