psql is the PostgreSQL client program that comes with PostgreSQL. It's for command-line use and assumes you know SQL. (For SQL-phobics and GUI-grown, I can recommend pgaccess or GNOME Transcript.)

It is vastly more featureful than the "mysql" tool that comes with MySQL and IIRC it had Readline support earlier too, thus being somewhat more comfortable. Also, it has complete help system, something mysql still doesn't have.

Typically, all you need to do is to type some SQL to the prompt, or use internal commands that, as in MySQL, start with slash (\). With command \?, you get help with the slash commands.

Some important commands:

\h command
Get help for SQL command. (Bare \h lists known SQL commands.)
\d table
Show the columns of a table.
Show list of everything in the current database.
List all tables in current database.
List all databases.
\c database [user]
Connect to the specified database (as user, if specified).
\i file
Execute commands from file.
\o file
Redirect output to file.

Useful command-line examples:

psql database
Connect to database as default user.
psql -c "command;" database
Execute SQL command command; and exit.
psql -W -U user database
Connect to the specified database as specified user; prompt for password.
psql -f file.sql database
Execute the commands from file.sql and exit.

Log in or registerto write something here or to contact authors.