Database Reference
In-Depth Information
The last interactive command you'll need is:
postgres=# \quit
Unfortunately, you cannot type "quit" on its own, nor can you type "\exit" or other options.
Sorry, just "\quit" or "\q" for short.
How it works...
psql allows you to enter the following two types of command:
F psql "meta-commands"
F SQL
A meta-command is a command for psql client, whereas SQL is sent to the database server.
An example of a meta-command is "\q", that tells the client to disconnect. All lines that begin
with "\" (backslash) as the non-blank first character are presumed to be meta-commands of
some kind.
If it isn't a meta-command, then it's SQL. We keep reading SQL until we find a semicolon, so
we can spread SQL across many lines and format it any way we find convenient.
The help command is the only exception. We provide this for people who are completely lost,
which is a good thought, so let's start there ourselves:
There are two types of help, which are as follows:
F \? provides help on psql meta-commands
F \h provides help on specific SQL commands
For example:
postgres=# \h DELETE
Command: DELETE
Description: delete rows of a table
Syntax:
DELETE FROM [ ONLY ] table [ [ AS ] alias ]
[ USING usinglist ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ AS output_name ] [,]]
I find this a great way to discover or remember options and syntax.
You'll also like the ability to scroll back through the previous command history.
 
Search WWH ::




Custom Search