$ psql test
SELECT CURRENT_USER; #special username query
SELECT 1 + 3; #can do arithmetic
SELECT 1 + #can do multi-line
3 + 5 +
6\p #can print out current buffer contents
\q #quit
create databases:
$ createdb willn
CREATE DATABASE
list databases:
test=# \list (or \l)
List of databases
Database | Owner | Encoding
-----------+----------+-----------
template0 | postgres | SQL_ASCII
template1 | postgres | SQL_ASCII
test | postgres | SQL_ASCII
(3 rows)
By looking through the source code, one can find that the actual
SQL statement for this command is:
SELECT datname FROM pg_database WHERE datname !~ '^template';
describe tables:
test=# \d
List of relations
Name | Type | Owner
--------+-------+-------
friend | table | willn
(1 row)
Again, this is equivalent to the following SQL command:
SELECT relname FROM pg_class WHERE relname !~ '^pg_';
|