Monday, August 31, 2009

Interacting with PostgreSQL

  • The psql client has a lot of features that will make your PostgreSQL life easier
  • Besides PostgreSQL commands (SELECT, INSERT, UPDATE, CREATE TABLE), psql provides meta-commands
  • PostgreSQL commands are sent to the server, meta-commands are processed by psql itself
  • A meta-command begins with a backslash character ( \ )
You can obtain a list of all the meta-commands using the \? meta-command :

postgres=# \?

General

\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]
connect to new database (currently "edb")

\h [NAME]
help on syntax of SQL commands, * for all commands)

\prompt [TEXT] NAME
prompt user to set internal variable

\password [USERNAME]
securely change the password for a user

\q
quit psql

\timing
toggle timing of commands (default off)

\! [COMMAND]
execute command in shell or start interactive shell

NOTE :
[ ] :
Optional Variables
| : denotes Or (a | b : a or b)

No comments:

Post a Comment

Followers