.. -*- coding: utf-8; -*-.. include:: HEADER.rst========== Postgre.==========.. contents::Installing on Debian.=====================Install and create new user and database:: $ sudo apt-get install postgresql postgresql-client $ sudo su - postgres % psql postgres=# CREATE USER "mypguser" WITH PASSWORD 'mypguserpass'; postgres=# CREATE DATABASE "mypgdatabase" OWNER "mypguser"; postgres=# \qConnect as user ``mypguser`` to new database:: $ su - mypguser $ psql mypgdatabase.. https://wiki.debian.org/PostgreSql Debian wiki instructions.List databases, schemas and tables.===================================Default database is ``postgres``.To list databases:: $ psql -U pgadmin -lor:: => SELECT datname FROM pg_database WHERE datistemplate = false; => \lTo switch databases:: => \connect NAMESchemas:: => select schema_name from information_schema.schemata; => select nspname from pg_catalog.pg_namespace; => \dn *To list all tables in the current database:: => SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name; => \dtSet default schema.===================:: set search_path to NAME;Using psql client.==================Using password file ``~/.pgpass``:: # comment hostname:port:database:username:password hostname:port:*:username:password hostname:*:*:username:passwordConnect by:: $ psql -U $USER -h $HOST $SCHEMA