postgre.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 23 Mar 2015 10:53:06 +0200
changeset 1700 f987c277f760
parent 1684 88f1d11d2adf
child 1701 6163ba5907d4
permissions -rw-r--r--
Using psql client.

.. -*- 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
  postgres=# CREATE USER "mypguser" WITH PASSWORD 'mypguserpass';
  postgres=# CREATE DATABASE "mypgdatabase" OWNER "mypguser";
  postgres=# \q

Connect as user ``mypguser`` to new database::

  $ su - mypguser
  $ psql mypgdatabase

..

  https://wiki.debian.org/PostgreSql
    Debian wiki instructions.

List all schemas and tables.
============================

Schemas::

  => select schema_name from information_schema.schemata;
  => select nspname from pg_catalog.pg_namespace;
  => \dn *

Using psql client.
==================

Using password file ``~/.pgpass``::

  # comment
  hostname:port:database:username:password
  hostname:port:*:username:password
  hostname:*:*:username:password

Connect by::

  $ psql -U $USER -h $HOST  $SCHEMA