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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1683
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
.. -*- coding: utf-8; -*-
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
.. include:: HEADER.rst
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
==========
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
 Postgre.
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
==========
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
.. contents::
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
Installing on Debian.
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
=====================
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
Install and create new user and database::
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
  $ sudo apt-get install postgresql postgresql-client
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
  $ sudo su - postgres
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
  postgres=# CREATE USER "mypguser" WITH PASSWORD 'mypguserpass';
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
  postgres=# CREATE DATABASE "mypgdatabase" OWNER "mypguser";
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
  postgres=# \q
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    20
Connect as user ``mypguser`` to new database::
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
  $ su - mypguser
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
  $ psql mypgdatabase
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
..
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
  https://wiki.debian.org/PostgreSql
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
    Debian wiki instructions.
d99b4a277679 Installing on Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
1684
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    30
List all schemas and tables.
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    31
============================
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    32
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    33
Schemas::
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    34
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    35
  => select schema_name from information_schema.schemata;
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    36
  => select nspname from pg_catalog.pg_namespace;
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    37
  => \dn *
88f1d11d2adf List all schemas.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1683
diff changeset
    38
1700
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    39
Using psql client.
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    40
==================
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    41
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    42
Using password file ``~/.pgpass``::
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    43
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    44
  # comment
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    45
  hostname:port:database:username:password
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    46
  hostname:port:*:username:password
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    47
  hostname:*:*:username:password
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    48
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    49
Connect by::
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    50
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    51
  $ psql -U $USER -h $HOST  $SCHEMA
f987c277f760 Using psql client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1684
diff changeset
    52