{{tag>databases postgres postgresql}}

====== PostrgeSQL ======

{{:system:images.png?300|}}

  * [[postgresql:postgresql|]]
  * [[https://postgrespro.ru/docs|Документация на русском]]
  * [[postgresql:postgresql:php-client|]]

====== Создание БД  ======

<note tip>Настраиваем доступ пользователю [[postgresql:postgresql#Настройка доступа|postgresql]]</note>

<code bash>
$ echo "ALTER USER postgres WITH ENCRYPTED PASSWORD 'postgres';" |sudo -u postgres psql
$ echo "CREATE DATABASE fias WITH OWNER postgres;" |sudo -u postgres psql
</code>

===== Создание дампа / Backup create =====

<code bash>
$ pg_dump database_name > database_name_20160527.sql
$ scp login@host:path_to_dir_with/database_name_20160527.sql database_name_20160527.sql
</code>

<code bash>
$ pg_dump -U postgres -d fias > fias.sql
$ pg_dump -U postgres -d fias | gzip > fias.gz
$ pg_dumpall > outfile.sql
$ pg_dump --host 127.0.0.1 --port 5432 --username "postgres" --no-password  --format plain --no-owner --no-privileges --no-tablespaces --verbose --no-unlogged-table-data --file "/dump3" "test"
$ sudo -u postgres pg_dump -U postgres -d fias -n public > /tmp/fias.sql
$ sudo -u postgres pg_dump -U postgres -d fias -n public --schema-only
</code>
===== Восстановление из дампа / Restore =====

<code bash>
$ psql template1 -c 'drop database database_name;'
$ psql template1 -c 'create database database_name with owner your_user_name;'
$ psql database_name < database_name_20160527.sql
</code>

<code bash>
$ psql park < ./park.sql
$ psql -h localhost -f dump2 -U postgres test
$ psql –h localhost –p 5432 --dbname=park --username=mirocow < park2.20151018_142522/park2.sql
$ gunzip < ./fias.gz | psql -U postgres -h localhost fias
</code>

===== Клиенты =====

  * [[https://dbeaver.jkiss.org/|DBeaver]] ([[os:windows|Windows]], [[os:macos|MacOS]], [[os:linux|Linux]]) на базе eclipse :!:
  * http://www.pgadmin.org/ (app: mac, linux, windows)
  * http://www.valentina-db.com/ (app: mac, linux, windows)
  * https://eggerapps.at/pgcommander/ (app: mac)
  * http://www.psequel.com/ (app: mac)
  * http://www.hankinsoft.com/SQLProPostgres/ (app: mac)
  * https://github.com/phppgadmin/phppgadmin (php)
  * https://github.com/sosedoff/pgweb (go)
  * https://github.com/dbcli/pgcli (app cli)
  * apt-get install phppgadmin (<text>git clone git://github.com/phppgadmin/phppgadmin.git</text>)

===== Документация =====

  * **[[http://postgresql.ru.net/manual/index.html|Документация]]** (RUS)
  * [[https://postgrespro.ru/docs/postgresql/9.6/index.html|PostgreSQL 9.6]] (RUS)
  * [[https://postgrespro.ru/docs/postgresql/10/index.html|PostgreSQL 10]] (RUS)
  * http://habrahabr.ru/hub/postgresql/
  * [[drupal:pgsql:1.8vs1.9|Разница в типах данных версий 1.8x и 1.9x]]
==== Компаненты / Настройка ====

  * http://www.postgresql.org/docs/8.3/static/textsearch.html
  * http://postgis.net/docs/manual-2.1/
  * https://github.com/le0pard/pgtune
  * http://pgtune.leopard.in.ua/
  * https://www.vividcortex.com/resources/network-analyzer-for-postgres/

===== Книжки/Статьи =====

  * http://postgresql.leopard.in.ua/

===== Ссылки =====

  * http://www.sql.ru/forum/actualtopics.aspx?bid=7
  * http://pembaca.summercode.com/simpleviewer/4cecbdfadd98231329000006/1
  * http://wiki.debian.org/ru/PostgreSql
  * http://ru.wikipedia.org/wiki/PostgreSQL
  * [[https://habrahabr.ru/company/postgrespro/blog/275755/|Обработка запросов в Oracle и PostgreSQL: следствия одного решения]]

====== Postgresql ======

{{topic>[postgresql]}}