������ �� ����� ���������� ������� �� PostgreSQL

���� ���������� ����������: ������� 30 ��� 22:24:56 EDT 2003

���������� ������� ������������: ���� ������ (Bruce Momjian) (pgman@candle.pha.pa.us)

������� �� �������: ������ ���������� (victor_v@permonline.ru)

����� ������ ���������� ������ ��������� ����� ����� �� http://www.PostgreSQL.org/docs/faqs/FAQ.html.

������ �� ������� ����������� ��� ���������� �������� ����� ����� �� http://www.PostgreSQL.org/docs/index.html.


����� �������

1.1) ��� ����� PostgreSQL? ��� ������������ ��� ��������?
1.2) ������ ��������� ����� �� PostgreSQL?
1.3) �� ����� Unix ���������� �������� PostgreSQL?
1.4) ���������� �� ������ ������������� �� �� Unix �������?
1.5) ��� ����� ����� PostgreSQL?
1.6) ��� �������� ���������?
1.7) ����� ��������� ������?
1.8) ����� ������������ ������� � �������?
1.9) ��� ����� ���������� �� ��������� ������� ��� ������������� ������������?
1.10) ��� ��������� SQL?
1.11) ������ �� � PostgreSQL �������� 2000-�� ���� (Y2K)?
1.12) ��� ������������� � ������� �������������?
1.13) ��� ��������� ��������� �� ������?
1.14) ��� ���������� PostgreSQL � ������� ����?
1.15) ��� ������� ���������� ������ PostgreSQL?

������� ������������� �� ���������� �����

2.1) ���������� �� ODBC �������� ��� PostgreSQL?
2.2) ����� ����������� ���������� ��� ������������� PostgreSQL ����� Web?
2.3) ���� �� � PostgreSQL ����������� ��������� ������������?
2.4) ����� ����� ����� ����������������� � PostgreSQL?

������� �����������������

3.1) ��� ��� ���������� PostgreSQL � ����� �������� �� /usr/local/pgsql?
3.2) ����� � �������� postmaster, � ������� ��������� Bad System Call ��� ��������� core dumped. ������?
3.3) ����� � ������� ��������� postmaster, � ������� ������ IpcMemoryCreate. ������?
3.4) ����� � ������� ��������� postmaster, � ������� ������ IpcSemaphoreCreate. ������?
3.5) ��� ��� ��������� ������������ � ������ �����������?
3.6) ����� ��������� ��� ����� ������� ��� ��������� ������������������?
3.7) ����� ����������� ��� ������� ���� � �������?
3.8) ������ � ������� ��������� "Sorry, too many clients" ����� ������� ������������ � ����?
3.9) ��� ��������� � �������� pgsql_tmp?
3.10) ������ ���������� ������ dump � restore ��� ���������� �������� PostgreSQL?

������� ������������

4.1) � ��� ������� ����� �������� � ���������� ��������?
4.2) ��� ��������� SELECT ������ ��� ���������� ������ ������� �������? ��� ������������ ������?
4.3) ��� �������� ������ ������ ��� ������ ����������� � psql?
4.4) ��� ������� ������� �� ������� ��� �������� ţ ��� ������?
4.5) ������ ������������ ������� ��� �������, ������ � ���� ������?
4.6) ��� ����� ��������� ������������ � ���� ������ ����� ��� ���������� ������ �� �������� ���������� �����?
4.7) ��� ��� ���������, ��� ���������� ������ ��� �������, �������, ���� ������ � ������������?
4.8) � ���� �������� �������� ������� ��� �� ���������� ������������� ��������. ������?
4.9) ��� ���������� �� ��, ��� ����������� ��������� ��� ������?
4.10) ��� ����� R-tree ������?
4.11) ��� ����� Genetic Query Optimizer?
4.12) ��� ��� ��������� ����� ����������� ��������� � ����� ����������� �� �������� ���� ����� ����������� ���������? ��� ��� ������������ ������ ��� ������ ������������ �� �������� ����?
4.13) ��� � ���� ����������, ��� �������� ���� ����� NULL � �����-���� �������?
4.14) ������ ������� ����� ������� ����������� ������?
4.15.1) ��� ��� ������� ���� serial/�-����-�����������?
4.15.2) ��� ��� �������� �������� ��� ������� SERIAL?
4.15.3) �� ����� �� ���������� ���, ��� ������������� currval()nextval() �������� � �������������� � ������� ��������������?
4.15.4) ������ ����� �� ���� ������������������ �� ������������ ����� ��� ������ ����������? ������ ��������� ������� ��� ��������� � �������, ��� � ��������� ������������������/SERIAL?
4.16) ��� ����� OID? ��� ����� TID?
4.17) ��� �������� ��������� ������� ������������ � PostgreSQL?
4.18) ������ � ������� ������ "ERROR: Memory exhausted in AllocSetAlloc()"?
4.19) ��� ��� ������, ����� ������ PostgreSQL ��������?
4.20) ������ ��� ������ � ���� ������� �������� � ������� ������ "invalid large obj descriptor"?
4.21) ��� ��� ������� ������� ������� �� ��������� ����� ��������� ������� �����?
4.22) ������ ��� ����������, ������������ IN ��� �������� ���������?
4.23) ��� ��������� ������� ����������?
4.24) ��� ��������� �������, ������������ ��������� ��� ������?
4.25) ��� ��� ������� �� ������� ��������� �������?
4.26) ������ � �� ���� ������� ���������/������� ��������� ������� � �������� PL/PgSQL?
4.27) ����� ����� ���������� ����������?
4.28) ����� ����� ���������� ����������?

���������� PostgreSQL

5.1) � ������� ������� ������������ �������������. ����� � �������� �� � psql, ������ � ������� dump core?
5.2) ��� � ���� ������ ��������� �������� ����� ���� � ������� � PostgreSQL?
5.3) ��� ��� �������� C �������, ������������ ������?
5.4) � ������� �������� ����. ������ ����� �������������� � �� ���� ���������?

����� �������

1.1) ��� ����� PostgreSQL? ��� ������������ ��� ��������?

PostgreSQL ������������ Post-Gres-Q-L (����-����-���-��).

PostgreSQL - ��� ���������� ���� POSTGRES, ����������������� �������� ������ ��������� ����. PostgreSQL ������������ ��������� ������ ������ ������ � �������� ���������� ����� POSTGRES, � �������� ���� �������� PostQuel �� ����������� ������������ SQL. PostgreSQL - ��� ��������� � ��������� �������� ����������� �����������.

���������� PostgreSQL ��������� ������� �������������, ��� ��������� ������� ��������� �� ������ �������� �������������. � ��������� �����, �� ������������� �������� ���� ������ (Marc G. Fournier) (scrappy@PostgreSQL.org). (��. ������ 1.6 � ���, ��� ������������ � ����������). ��� ������� ������ �������� �� ��� ���������� PostgreSQL.

�������� PostgreSQL 1.01 �������� ����� � (Andrew Yu) � ����� ��� (Jolly Chen). ������ ������ ������ ���� ����� � ������� �� ������ ���������, ������������, ������� � ���������� ����� ����. �������������� ��� Postgres, �� �������� �������� PostgreSQL, ��� ������ ������ ������ ������������� ���������, ��������������� ��������� � ��������� ������ �������������, ���������� ��� ������������ ���������� ������ ������������� (Michael Stonebraker) � �������������� ������������, ������.

�������������� ���, ������ � ������, ���� Postgres. ����� � 1995 ���� ���� ��������� ���������������� SQL, ��� ��� ���� �������� �� Postgres95. �� � ��� ��� ���� �������� � ����� 1996 �� PostgreSQL.

1.2) ������ ��������� ����� �� PostgreSQL?

PostgreSQL �������� ��� �������� ���������� COPYRIGHT:

������� ���������� ������ ������ PostgreSQL

Portion copyright (c) 1996-2002, PostgreSQL Global Development Group Portions Copyright (c) 1994-6 Regents of the University of California

��������������� ����� �� �������������, �����������, ��������� � ��������������� ������� ������������ ����������� � ��� ������������ ��� ����� �����, ��������� � ��� ���������� ������-���� ����������, ��� ������� ��� ��� ������ ����� ����� ������������� ������ ���� ��������� �� ��������� ������, ������� �������� � ��� ��������� ���������.

�������������� ����������� �� ����� ������� ��������������� �� ����� �����������, ������� ������ ������, ���������� ������ ��� ��������, ����������� ��� ��������� �������������� ������� ������������ ����������� ��� ��� ������������, ���� ���� �������������� ����������� ��� ������� � ����������� ����� �����������.

�������������� ����������� ���������� ���������������� ������������� ����� ��������, �������, �� �� ������������� ������ ����� ����������: ������� �������� ����������� ������ ��� ����������� ��� ��������� ����. ������ ����������� ����������� ��������������� �� ������ ������� "��� ����" � �������������� ����������� �� ������ ������������� �������������, ���������, ����������, ���������� ��� ���������.

�������������� �������� BSD ���������, ������������ ��������� ������������ ����������� � �������� �����. ��� �������� �� ����������� ����������� �� ������������� ��������� ����. ��� �������� ��� �������� � �� �� ���������� ţ ������.

1.3) �� ����� Unix ���������� �������� PostgreSQL?

������, PostgreSQL ����� �������� �� ����� ����������� ��������� ����������� � Unix. � ���������� �� ���������, �� ������� ������ ��� ��������, �� ������� ���� ��������� �������� ������� PostgreSQL � ������� ������ ������ ������.

1.4) ���������� �� ������ ������������ �� �� Unix �������?

������

��� ������� �� ���������� MS Windows �������� ���������� C ���������� libpq, psql, ������ ���������� � ���������� ����������. � ���� ������, ������ ����������� �� MS Windows � ����������� �� TCP/IP � ��������, ���������� �� ����� �� �������������� Unix ��������. � ����������� ���������� ���� win32.mak ��� ����, ����� ����� ���� �������� ������ ���������� libpqpsql ��� Win32. PostgreSQL ����� �������� ����� ODBC.

������

������ �� ����� ���� ������� �� Windows NT � Win2k, ��������� ���������� Cygwin, ������������� ��������� Cygnus ��� �������� ������������ ����������� Unix � NT. �������� pgsql/doc/FAQ_MSWIN � ������������ ��� MS Windows FAQ �� http://www.PostgreSQL.org/docs/faqs/text/FAQ_MSWIN.

PostgreSQL, �������������� ���������� ��� MS Win NT/2000/XP � ��������� ������ ����� ��������. ����������� �������� ��������� PostgreSQL ��� Windows �������� �� http://techdocs.postgresql.org/guides/Windows.

����� ���������� ������ �������������� ��� Novell Netware 6 �� http://forge.novell.com.

1.5) ��� ����� ����� PostgreSQL?

��������, ���������������� ��������� �������� �� ftp ���� PostgreSQL ftp://ftp.PostgreSQL.org/pub. ������ ������ �� ������� �� ����� �������� �����.

1.6) ��� �������� ���������?

�������� ������ ��������: pgsql-general@PostgreSQL.org. � ��� ����� ��������� ����� ����, ���������� PostgreSQL. ����� �����������, ��������� ������ �� ����������� �����, � ������� � ���� ������ (�� � ����) �������� ��������� ������:

    subscribe
    end

�� ����� pgsql-general-request@PostgreSQL.org.

���������� ������� ������. ����� ����������� �� ����, ��������� ������ �� ����������� ����� �� �����: pgsql-general-digest-request@PostgreSQL.org � � ���� ������ �������� ������� �������:

    subscribe
    end
�������� ������������ �����������, ����� � �������� ������ �������� ��������� ����� 30 �������� ���������.

�������� � ������ �������� ��������� �� �������. ����� ����������� �� ���� ������, ��������� �� ����������� ����� ������ �� ����� pgsql-bugs-request@PostgreSQL.org � � ���� ������ �������� ������� �������:

    subscribe
    end
����� ������� ������ �������� � ����������� �������������. ����� ����������� �� ���� ������, ��������� �� ����������� ����� ������ �� ����� pgsql-hackers-request@PostgreSQL.org � � ���� ������ �������� ������� �������:
    subscribe
    end

�������������� ������ �������� � ��������� � PostgreSQL ����� ����� �� �������� ��������� PostgreSQL �� ������:

http://www.PostgreSQL.org

��� ���������� IRC ����� �� EFNet � OpenProjects, � ��������� #PostgreSQL. � ��������� ��� ����������� � ����� ������ ������� Unix irc -c '#PostgreSQL' "$USER" irc.phoenix.net.

������ ������������ ��������� �������� �������� �� http://www.ca.PostgreSQL.org/users-lounge/commercial-support.html.

1.7) ����� ��������� ������?

��������� ������ PostgreSQL - ��� ������ 7.3.2.

�� ��������� ��������� ����� ������ ������ ������ ������.

1.8) ����� ������������ ������� � �������?

� ����������� ���������� ��������� �����������, �������� ������������ ����������� man � ��������� ��������� �������� �������. �������� � ������� /doc. �� ����� ������ ������������� ������������ � �������� �� ������ http://www.PostgreSQL.org/docs.

���������� ��� ����� �� PostgreSQL ��������� �� ������� http://www.PostgreSQL.org/docs/awbook.htmlhttp://www.commandprompt.com/ppbook/. ������ ���� �� PostgreSQL, ������� ����� ������ �������� �� ������ http://www.ca.PostgreSQL.org/books/. ����� ����, �� ������ http://techdocs.PostgreSQL.org/ �� ������ ����� ��������� ����������� ������ ����������� PostgreSQL.

psql ����� ��������� ���������� ������ \d ��� ����������� ���������� �� �����, ����������, ��������, ��������� � �.�.

��� ���� �������� ��� ������ ����������.

1.9) ��� ����� ���������� �� ��������� ������� ��� ������������� ������������?

PostgreSQL ������������ ����������� �������� SQL-92. �������� ��� ������ TODO �� ������� ��������� ������, ������������� ������������ � ������� ������.

1.10) ��� ��� ��������� SQL?

����� �� PostgreSQL �� http://www.PostgreSQL.org/docs/awbook.html ������ SQL. ���������� ������ ����� �� PostgreSQL �� http://www.commandprompt.com/ppbook. ���� ���������� ������� �� http://www.intermedia.net/support/sql/sqltut.shtm, �� http://ourworld.compuserve.com/homepages/graeme_birchall/HTM_COOK.HTM, � �� http://sqlcourse.com.

��� ���� ������� - ��� ����� "Teach Yourself SQL in 21 Days, Second Edition" (����� �������������� SQL �� 21 ����, ������ ��������) �� http://members.tripod.com/er4ebus/sql/index.htm

������ �� ����� ������������� �������� ����� The Practical SQL Handbook, Bowman, Judith S., et al., Addison-Wesley. ������ �������� The Complete Reference SQL, Groff et al., McGraw-Hill.

1.11) ������ �� � PostgreSQL �������� 2000-�� ���� (Y2K)?

��, �� ����� �������� � ������ ����� 2000 ���� � ����� 2000 �����.

1.12) ��� ������������� � ������� �������������?

��� ������, �������� ��������� ������ �������� ������� � �������� ������������ ������������� PostgreSQL �� ����� ����� ��� � ������������. �����, ����������� �� ������ �������� pgsql-hackerspgsql-patches. �����, ����������� ����������� (patches) �������� �������� � ������ pgsql-patches.

���������� ������������ ������ �����, ������� ����� ���������� ������� ��������� � CVS ����� PostgreSQL. ������ �� ���� ����� � ���� ����� �������� ��� ����� ������������������ �����������, ��� �� ���� ���������� �������� ��� �������� � ��� ���� ��������� ���������� ������� ���������, � �� �������, ��� �� �����������, ������� ��� ������ ����� �������� ��������.

1.13) ��� ��������� ��������� �� ������??

���������� �������� ��������� PostgreSQL BugTool �� http://www.PostgreSQL.org/bugs/bugs.php, �� ������� ������������� ��������� ���������� � ��� ��� ��������� ��������� �� ������.

����� �� �������� ���������� �� ftp://ftp.PostgreSQL.org/pub �� ������� ����� ������ ������ PostgreSQL ��� ������.

1.14) ��� ���������� PostgreSQL � ������� ����?

���������� ��������� ������� ��������� ������������ �����������: �����������, ������������������, ����������, ��������� � ����.

�����������
PostgreSQL ����� ����������� ������������ �������������� � ������� ������������ ����, ����� ���: ����������, ����������, ��������, ������ (views), ������� ���� ��������� ����������� � ������ ����������. � ��� ���� ��������� �����������, ������� ��� � ���: ����, ������������ �������������, �������� ������������, ������� � ����������� ��������������� ���������� ��� ������ � ���������� ����������.

������������������
PostgreSQL ����� ������������������ ������ � ������� ������������� ���� � � ���� � �������� �������� �����, � �����-�� �������� ������� ������� ��� ���, � �����-�� ��������. � ��������� � MySQL ��� ��������� ����, �� �������� ��� ��������� �������/����������, ������ ��� ��������� ������������. � ����������, MySQL �� ����� �����-���� ������������ �� ������������ ����, � ������ �����������. �� ������ ���� �� ���������� � ����������� �����������, �� �� ����� ���������� ����������� ������������������ � ������ ��������. ���������� ���������� ��������� � ��������, ������������ PostgreSQL � MySQL �� http://openacs.org/philosophy/why-not-mysql.html

����������
�� ��������, ��� ���� ���� ������ ���� �������� ��� ��� ������ �� ����� ������. �� ��������� ��������� ������ �����������, ���������� ���, ������� �������� ������� ������. ������ ������ �������� ������ ����-������������ �� ������� ���� � ������� ������ ������ � ���� ������� �������� ���������� ��� �� ����� ������������� ����������, ���������� �������, ������� ������ � ������������� �������������. �� �����, ��� �� ���������� �������� �� ����, ��� � ������ ����.

���������
��� ������ �������� ������������� �������������� ������� � ������� ������� ������������� � �������������, ������� ����� ������ ������ ����� ��������� ��������. � �� �� �����, �� �� ����������� �����-���� �����������, �� � ������������ ������������ ���� �� ������ ������ �����������. ������ ������ � �������������, ���������� �������������, ������������ � �������� ������� ����� ������ ��������� PostgreSQL ������������� ������ ����. ���������� ������������ ��������� �� ��������� ��������� ����������, ������� �������� ��� ��� ���� ��� �����. (�������� ������ 1.6.)

����
��� ������� ��������� ��� ��� ������������� ���, � �� ��� ������������� �������������. �� ������ ��������� ���� ��� � ��� ������� ��� �����������, �� ����������� ���, ��� ����������� � ����� �������� ����� BSD, ������� ��������� ����.

1.15) ��� ������� ���������� ������ PostgreSQL?

PostgreSQL ����� ������������ �������������� � ���� ������ ������� ��� �� ������ ���������� � 1996 ����. �� ������ ����������� �� ��� ����� ����� (Marc Fournier), ������� ������ ��� �������������� � ��������� �� �� ���������� ���� ���.

������������ �������������� ����� ����� ��� �������� � �������� �������� �����. ��� ������������� �������, ������� ����� ������ ��������� �������������� �������� �������.

����������, ��� �������������� �� �������� �������. ���������� ��������� ���������� ����������� � ����������� ��������, ������� ������� �����. ���� �� ��� ���� �������� ����� ������, ������� ����� �������� � ������ ����� �������, ���������� �������� ��������� https://store.pgsql.com/shopping/ � �������� ���� �����.

���� �� ��������� ��������� � PostgreSQL, Inc, ����� "contributions" ������������ ������������� ��� ��������� ������� PostgreSQL � �� ���������� �����-���� ���������� ��������. ���� ������, �� ������ ��� ���������, ������� ������ �� ���������� �����.


������� ������������� �� ���������� �����

2.1) ���������� �� ODBC �������� ��� PostgreSQL?

���������� ��� ODBC ��������, PsqlODBC � OpenLink ODBC.

�� ������ ������� PsqlODBC � http://gborg.postgresql.org/project/psqlodbc/projdisplay.php.

OpenLink ODBC ����� ����� �� http://www.openlinksw.com. ���� ������� �������� � �� ����������� ���������� ����������� ������������, ������������ ODBC, � ����� �������, ODBC �������� ��� PostgreSQL �������� ��� ������ �� �������������� ��� �������� (Win, Mac, Unix, VMS).

�������� ��� ����� ��������� ���� ������� ��� ���� ����� ������������ ���������, �� ���������� ������ ������ ����� ��������. ����������, ����������� ������� �� ����� postgres95@openlink.co.uk.

2.2) ����� ����������� ���������� ��� ������������� PostgreSQL ����� Web?

���������� �������� �� �������������� ��� ������ � Web ����� ����� ��: http://www.webreview.com

��� ���������� � Web, ����� �� ������������ ������������ �������� PHP. �������� �������� http://www.php.net.

��� ����������� �������, ������ ���������� Perl ����������� � CGI.pm ��� mod_perl.

2.3) ���� �� � PostgreSQL ����������� ��������� ������������?

��, ���������� ��������� ����������� ����������� ��� PostgreSQL. ��� PgAccess (http://www.pgaccess.org, PgAdmin II (http://www.pgadmin.org, Win32-only), RHDB Admin ( http://sources.redhat.com/rhdb/) � Rekall ( http://www.thekompany.com/products/rekall/, ������������). ����� ���� PHPPgAdmin ( http://phppgadmin.sourceforge.net/) - ��������� � PostgreSQL, ���������� �� Web.

2.4) ����� ����� ����� ����������������� � PostgreSQL?

�����-���� ���������� ��� PostgreSQL ���������� ��� ����������� ���������� ������ ����������������. ���������� ������ ������� ���������� ��� ��� ������ ����������������, �������� �� �����������.

��������� ���������� ���������� � ����������� PostgreSQL:

�������������� ���������� �������� �� ������ http://gborg.PostgreSQL.org � ������ Drivers/Interfaces.


������� �����������������

3.1) ��� ��� ���������� PostgreSQL � ����� �������� �� /usr/local/pgsql?

������� ����� --prefix ����� ���������� configure.

3.2) ����� � �������� postmaster, � ������� ��������� Bad System Call ��� ��������� core dumped. ������?

��� ����� ���� ������� ������� ����������, �� ������, ��� ����� ������� - ��� ��������� � ���, ��� � ����� ���� ����������� ���������� System V. PostgreSQL �������, ����� ���� ������������ ����������� ������ � ��������.

3.3) ����� � ������� ��������� postmaster, � ������� ������ IpcMemoryCreate. ������?

���� � ��� � ���� ������������ ��������� ����������� ������, ���� ������ ���� ����� ������� ���������� ��������� ����������� ������. �� ���������� ��������, ������� ��� ����� ���������� ������� �� ����������� ����� ������ � �� ���� ��� ����� ������� � backend ��������� �� ��������� ��� postmaster. ��� ����������� ������, � ����������� ������� � ��������� �� ���������, ����������� ������� - ��� ����� 1 ���������. ����������� � ����������� ������ � ��������� �������� � ����������� �������������� PostgreSQL.

3.4) ����� � ������� ��������� postmaster, � ������� ������ IpcSemaphoreCreate. ������?

���� ��� ��������� IpcSemaphoreCreate: semget failed (No space left on device) �� ��������� ������ ���� ������, ��� ��� �� ������� ���������. Postgres ������� ���� ������� �� ������������� backend �������. ��������� �������� �������� ������ postmaster � ����������� �� ������� ���������� backend ���������. ����������� -N � ��������� ������� ��� 32, ������� ������� �� ���������. ����� ���������� ������� - ��� ��������� �������� SEMMNSSEMMNI � ��������� ����.

����������� �������� ����� ����� �������� � ������� ���� �� ����� ������� � ���� ������.

���� �� �������� �����-���� ������ ��������� �� ������, �� ������ ��������, ��� � ����� ���� ������ �� ��������� ��������� ���������. �������� ����������� � ����������� ������ � ��������� � ����������� �������������� PostgreSQL.

3.5) ��� ��� ��������� ������������ � ������ �����������?

�� ���������, PostgreSQL ��������� ������ ���������� �� ��������� ������ ����� ������ ������ Unix. ������ ������ �� ������ ������������ � ���� ���� ��� postmaster �� ����� ����� ���� -i ���� �� ����� ��������� host-����������� � ����� $PGDATA/pg_hba.conf. ��� �������� ������ ���������� TCP/IP ����������.

3.6) ����� ��������� ��� ����� ������� ��� ��������� ������������������?

����������, ������� ����� ��������� �������� ���������� ��������. ������� EXPLAIN ��������� ��� ���������� ��� PostgreSQL �������������� ��� ������ � ����� ������� ������������.

���� �� ���������� ����� ���������� INSERT, ����������� ����������� ��������� �� � ������� �����, ��������� ������� COPY. ��� ����������� �������, ��� ��������� INSERT. ��-������, ��������� ��� ����� ���������� BEGIN WORK/COMMIT ���� ��������� ����������. ��������� ��� ����������� ���������� ���������� � ����� ����� ����������. ��� �������� ���������� ����������. �����, ����������� ��� ��������� � ������������� ��������, ����� �� ���������� ������� ��������� ������.

���������� ��������� ����� ���������. �� ������ ��������� fsync() ��� ������ postmaster � ������ -o -F. ��� ������������ ������ fsync(), ������� �������� � ������ ������ �� ���� ����� ������ ����������.

�� ������ ����� ������������ ��� postmaster ����� -B ��� ���������� ���������� ������� ����������� ������, ������� ������������ backend ����������. ���� �� �������� �������� ����� ��������� ������� �������, �� postmaster ����� �� ���������� ������ ��� �� ���������� ����������� ���� �� ����� ����������� ������. ������ ����� ����� ������ � 8 �������� � �� ��������� ���������� 64 ������.

�� ������ ����� ������������ backend ����� -S ��� ���������� ������������� ���������� ������, ������� ������������ backend ��������� ��� ��������� ����������. �������� ��� ����� -S �������� � ���������� � �� ��������� ����� 512 (�.�. 512K).

�� ����� ������ ������������ ������� CLUSTER ��� ����������� ������ � �������� �� ����������� ������. ����������� �������� �� �������� ����������� �� ������� CLUSTER.

3.7) ����� ����������� ��� ������� ���� � �������?

PostgreSQL ����� ��������� ������������, ����������� �������� ���������� � ���������, ������� ����� ���� ������������ � ���������� �����.

��-������, ��� ������� configure � ������ --enable-cassert, ������ ������ assert() ��������� ����������� ������ backend �������� � ��������� ��������� ��� ������������� �����-���� ��������������.

postmaster, � postgres ����� ��������� ���������� �����. ��-������, ��� ������� postmaster, ���������, ��� ����������� ����� � ����� ������ �������������� � ���� �������:

    cd /usr/local/pgsql
    ./bin/postmaster >server.log 2>&1 &

��� �������� � ��������� ����� server.log � ������� �������� PostgreSQL. ���� ���� �������� �������� ���������� � ��������� ��� �������, ��������� �� �������. Postmaster ����� ����� -d, ������� ��������� �������� ��� ���������������� ����� ��������� ���������. ��� ����� -d ����������� �����, ������� ������ ������� �������. ������ ���������, ��� ��� ������� ������� ������� �������� � ��������� ������ ������� �������� �������.

���� postmaster �� �������, �� ������ ��������� postgres backend �� ��������� ������ � ������ ��� �������� SQL ��������. ��� ������������� ������ ��� ����� �������. �������, ��� � ���� ������, ������ ����������� �������� ����� ������, � �� ������ � �������. ���� �� ����������� ���������� � ����������� ����������, �� ������ ������������ ����� ��������, ����� ����������, ��� ���������. ��������� backend ����������� �� �� postmaster, �� �� ����������� � ���������� ��������� � ������ �������� �������� ����������/backend �� ����� ���� ��������������.

���� postmaster �������, ��������� psql � ����� ����, ����� ������� PID �������� postgres, ������������ psql. ����������� �������� ��� ����������� � postgres PID. �� ������ ���������� ����� ���������� � ��������� � ��������� ������ �� psql. ���� �� ����������� ������� ������� postgres, �� ������ ���������� PGOPTIONS="-W n", � ����� ��������� psql. ��� ����� �������� � �������� �������� ������� �� n ������, � ������� ������� �� ������ ���������� � �������� ��������, ���������� ����� ����� ���������� � ���������� ������.

��������� postgres ����� ����� -s, -A, � -t ������� ����� ���� ����� ��������� ��� ������� � ��������� ������������������.

�� ����� ������ �������������� PostgreSQL � ��������������� ��� ����, ����� ������� ����� ������� ������� ������� �����������. ����� �������������� backend'� ��������� � �������� pgsql/data/base/dbname. ���� �������������� ������� ����� ������� � ������� ������� �������. � Linux ��� ���������� �������������� ��������� ���������� � -DLINUX_PROFILE.

3.8) ������ � ������� ��������� "Sorry, too many clients" ����� ������� ������������ � ����?

��� ����� ��������� ����������� �� ���������� ����������� backend ��������� ��� ������� postmaster.

�� ��������� ���������� ����� �� 32 ��������. �� ������ ��������� ���� ����� ������������ postmaster � ������ ��������� ���������, ������� ����������� � ����� -N ��� ������� ���� postgresql.conf.

�������, ��� ���� �� �������� � ����� -N �������� ������ 32, �� �� ����� ������ ��������� �������� � ����� -B ������� �� ��������� ����������� � 64; �������� ����� -B ������ ���� �� ������� ���� ����� ������ �������� ����� -N, � �������� �ݣ ������ ��� ������ ������������������. ��� �������� ���������� backend ���������, ��� ����� ������� ���� �� ��������� ��������� ��������� ���� Unix. ��� ����� ���������, ��� ������������ ���������� ������ ����������� ������, SHMMAX; ������������ ���������� ���������, SEMMNSSEMMNI; ������������ ���������� ���������, NPROC; ������������ ���������� ��������� �� ������������, MAXUPRC; � ������������ ���������� �������� ������, NFILENINODE. ������� �������� ����������� �� ���������� backend ��������� ��� ��� � ������� � ���, ����� ����� ������� ������� ��������.

3.9) ��� ��������� � �������� pgsql_tmp?

������ ������� �������� ��������� �����, ������������ ������������ �������. ��������, ���� ��� ���������� ORDER BY ����� ���������� � ��� ���������� ������� ������ ������, ��� ��������� �������� -S � backend'�, �� ��� �������� �������������� ������ ��������� ��������� �����.

��� ��������� ����� ������ ��������� �������������, �� ����� ����� �� ���������, ���� backend ������ �� ����� ����������. ������� � ������ ���������� �������� ��������� �� �������� �� ��������.

3.10) ������ ���������� ������ dump � restore ��� ���������� �������� PostgreSQL?

������������ PostgreSQL ������ ������ ��������� ��������� ����� ������������. ����� ������� ���������� � ������ 7.2 �� 7.2.1 �� ������� ���������� dump � restore. ������ ��� ������ ���������� ������� (�.�. ��� ���������� ��������, � 7.2 �� 7.3) ����� �������� ���������� ������ ��������� ������ � ������ ������. ��� ��������� ����� ����� ����������� ��������, ��� ��� ��� ����������� ���������� �������� ������������� ������ ������. ��������� dump ��������� �������� ������ � ����� �������, ������� ����� ����� ���� �������� ��� ������������� ������ ����������� �������.

� ��� ��������, ��� ������ ������ �� ����� �� ��������, ��� ���������� ���������� ����� ���� ����������� �������� pg_upgrade ��� ������������� dump/restore. ����������� � ������� ������� ����� ����� ������������ pg_upgrade ��� ����� �������.


������� ������������

4.1) � ��� ������� ����� �������� � ���������� ��������?

�������� �������� �� ��������� ����������� ����������� DECLARE.

4.2) ��� ��������� SELECT ������ ��� ���������� ������ ������� �������? ������������ ������?

�������� ������� ����������� ����������� FETCH ��� ����������� SELECT ... LIMIT....

���� ���� �� ������ �������� ������ ������ ��������� �������, ����� �������� ���� ������. ���������� ������, ������� ����� ORDER BY. ���� ���� �����-���� ������, ������� ��������� � ORDER BY, PostgreSQL ����� ������ ������ ��������� ������ ����������� ������� ��� ����� ��������� ������ ���� �� ����� ������ �������� ������.

To SELECT a random row, use:

    SELECT col
    FROM tab
    ORDER BY random()
    LIMIT 1;

4.3) ��� �������� ������ ������ ��� ������ ����������� � psql?

�� ������ ���������� �������� ��� psql � ����� pgsql/src/bin/psql/describe.c. �� �������� ������� SQL ������� ������������ ��� ����� � psql ������, ������������ � �������� ����� �����. �� ����� ������� ��������� psql � ������ -E ���, ����� ��� ��������� �������� �������, ������� ��� ���������� ��� ���������� �������� ���� ������.

4.4) ��� ������� ������� �� ������� ��� �������� �� ��� ������?

DROP COLUMN ���������������� ���� ��������� � ������ 7.3 � ���������� ALTER TABLE DROP COLUMN. � ������ �������, ����� ������� ���:

    BEGIN;
    LOCK TABLE old_table;
    SELECT ...  -- ������� ���� ������� �� ����������� ���, ������� ������ �������
    INTO TABLE new_table
    FROM old_table;
    DROP TABLE old_table;
    ALTER TABLE new_table RENAME TO old_table;
    COMMIT;

��� ��������� ���� ������ �������, �������� ���:

    BEGIN;
    ALTER TABLE tab ADD COLUMN new_col new_data_type;
    UPDATE tab SET new_col = CAST(old_col AS new_data_type);
    ALTER TABLE DROP COLUMN old_col;
    COMMIT;

4.5) ������ ������������ ������� ��� �������, ������ � ���� ������?

���������� ��������� �����������:

    ������������ ������ ����?              ����������� (���������� ���� �� 4 TB)
    ������������ ������ �������?           16 TB
    ������������ ������ ������?            1.6 TB
    ������������ ������ ����?              1 GB
    ������������ ���������� ������� � �������?      ������������
    ������������ ���������� ������� � �������?    250-1600 � ����������� �� ����
    ������������ ���������� �������� � �������?   ������������
����������, ������� "������������" �� ����� ���� �������������� ��������� �������� �������������� � ��������� ������/���������. ����� �������� ������������� ���� ����������� �������, ����� ���������� ������������������.

������������ ������ ������� � 16 TB �� ������� ����� ������������ ������� ������������ ����� ������� ��������. ������� ������� �������� ��� ��������� ������ �������� � 1 GB, ��� ��� �����������, ������� ����������� �������� ������� �� �����.

������������ ������ ������� � ������������ ���������� ������� ����� ���� ���������, ���� ������ ����� �� ��������� ����� �������� �� 32k.

4.6) ��� ����� ��������� ������������ � ���� ������ ����� ��� ���������� ������ �� �������� ���������� �����?

���� PostgreSQL ����� ������������� ��������� ������������ �� 5 ��� ������ ��� ���������� ������ �� �������� ���������� �����.

� �������� �������, ���������� ���� � 100,000 ����� � ������, �� ������� ����� ����� � ��������� ��������. ��� ���� ����� ������, � �������, ���������� 20 ����. ������ �������� ����� �������� 2.8 MB. ������ ���� PostgreSQL, ���������� ��� �� ������ �������� �������������� 6.4 MB �� �������:

    36 ����: �� ������ ��������� ������ (��������������)
  + 24 �����: ���� ���� � ������������� ����� � ���� ��������� ����
   + 4 �����: ��������� �� �������� ��� ���� ������
   ----------------------------------------
    64 ���� �� ������

   ������ �������� ������ � PostgreSQL ���������� 8192 ���� (8 KB), ��� ���:

   8192 ���� �� ��������
   -------------------   =  128 ������� �� �������� �� (� �����������)
     64 ���� �� ������

   100000 ����� ������
   --------------------  =  782 �������� � ��
  128 ������� �� ��������

782 �������� �� * 8192 ���� �� ��������  =  6,406,144 ���� (6.4 MB)

������� �� ������� ��� �����, �� ��������� ��� ��������� ��� �������� ���������� ������, ��� ����� ����� ���� ������.

�������� NULL ����������� � ����� � ������� ��� �������� ����� ���� �����.

4.7) ��� ��� ���������, ��� ���������� ������ ��� �������, �������, ���� ������ � ������������?

psql ����� ��������� ������, ������������ � �������� ����� �����, ��� ���� ����� ������������� ����� ����������. ����������� \? ��� ����, ����� ������� ��� �������. ����� ���������� ��������� �������, ��� ������� ���������� �� pg_ � � ������� ����� ���������� ��� ����������. �ݣ, psql -l ������� ������ ���� ��� ������.

����� �������� ���� pgsql/src/tutorial/syscat.source. � ��� ������������ ������ ��������� SELECT ������� ����� ��� ��������� ���������� �� ��������� ������ ���� ������.

4.8) � ���� �������� �������� ������� ��� �� ���������� ������������� ��������. ������?

������� �� ������������ ��� ������� ������� �������������. ��� ������������ ������ ���� ������� ������ ������������ ������� � ������ �������� ������ ��������� ������� ������� � �������. ��� ��������, ������ ��� ������ � ����� � ����������� ������������ ��� ������������ �������� ����� ���� ���������, ��� ������� ������ ������� ��� �� ���������������� ������������.

����� ���������� ������������� ������������� ������� ��� �����-���� �������, PostgreSQL ������ ����� ���������� �� ���� �������. ��� ���������� ���������� ��� ������������� VACUUM ANALYZE ��� ������ ANALYZE. ��������� ����������, ����������� ������ � ��� ��� ����� ������� � ������� � ���� �� ������ ������������ �������, �� �� ����� ��������� ������ �������. ���������� ����� ������ �� ����������� ������������ ������� ���������� � ������ ����������. ���� ���������� ������ ������������ ���������� ��� ��������� ����������� �������.

������ ������� �� ������������ ��� ORDER BY ��� ��� ���������� ����������. ���������������� ������� ��������� �� ����� ����������� ������ �������, ��� ����� �� �������� � ������� �������. ������, ORDER BY ����� ������������� � LIMIT � � ���� ������ ������ ����� ��������������, ��������� ��� ���������� ����� ������������ ��������� ����� �������. ���������� MAX() � MIN() �� ���������� �������, �� ������ ������������ ��� ���������� �������� � ORDER BYLIMIT:

    SELECT col
    FROM tab
    ORDER BY col [ DESC ]
    LIMIT 1;

���� ��� �������, ��� ����������� ���������� �������� ���������������� �������, ����������� SET enable_seqscan TO 'off' � ��������� �����, ����� �������, �� �����-�� ������������ �������� �������.

����� ������������ �������� � ���������, �������� LIKE ��� ~, ������� ����� ���� ������������ � ��������� �������:

4.9) ��� ���������� �� ��, ��� ����������� ��������� ��� ������?

�������� �������� ����������� ����������� EXPLAIN.

4.10) ��� ����� R-tree ������?

R-tree ������ ������������ ��� �������������� ���������������� ������. ������ ���� �� ����� ��������� �������� ���������. B-tree ������ ��������� ������ �������� ��������� � ����� ���������. R-tree ������ ����� ��������� ��������������� �������. ��������, ���� R-tree ������ ����� ���� ������� � ������� ���� point, �� ������� ����� ����� ���������� �������� �� ������ ���� "������� ��� ����� ������ ��������� ����������������."

������������ ��������, ����������� �������������� �������� R-tree ���:

Guttman, A. "R-trees: A Dynamic Index Structure for Spatial Searching." Proceedings of the 1984 ACM SIGMOD Int'l Conf on Mgmt of Data, 45-57.

�� ������ ����� ���� �������� � ����� Stonebraker'� "Readings in Database Systems".

����������� R-tree ����� ��������� ���������� � �������. � ������, R-tree ����� ���� ��������� ��� ���������� ������� ����������� ���������. �� ��������, ���������� R-tree ������� ��������� ������ � � ���, � ������ ������, ��� �����-���� ������������ � ���, ��� ��� �������.

4.11) ��� ����� Genetic Query Optimizer?

������ GEQO ���������� ������� ����������� �������, ����� ���������� ���������� ������ ������ ����� Genetic Algorithm (GA). ��� ��������� ��������� �������� ��������� �� ���������� ����� ������������ �����.

4.12) ��� ��� ��������� ����� ����������� ��������� � ����� ����������� �� �������� ���� ����� ����������� ���������? ��� ��� ������������ ������ ��� ������ ������������ �� �������� ����?

�������� ~ ���������� ����� ����������� ���������, � �������� ~* ���������� ����������� �� �������� ���� ����� ����������� ���������. ����������� �� �������� ������� LIKE ���������� ILIKE.

����������� �� �������� ��������� ������ ���������� ���:

    SELECT *
    FROM tab
    WHERE lower(col) = 'abc';
��� ����������� �� ����� ������������ ����������� ������. ������, ���� �� ��������� �������������� ������, �� ����� �����������:
    CREATE INDEX tabindex ON tab (lower(col));

4.13) ��� � ���� ����������, ��� �������� ���� ����� NULL � �����-���� �������?

�� ������ ����������� �������� � IS NULLIS NOT NULL.

4.14) ������ ������� ����� ������� ����������� ������?

���            ���������� ���   ���������
--------------------------------------------------
VARCHAR(n)      varchar         ������ ������ ������������ �����, ��� ����������
CHAR(n)         bpchar          ����������� �������� �� ������������� �����
TEXT            text            ��� ����������� �������� ����������� ��� �����
BYTEA           bytea           ������ ���� ���������� ����� (����� ������������ null-���� ��� ������)
"char"          char            ���� ������

���������� ��� �� ������ �������, ����� �������� ��������� �������� � � ��������� ���������� �� �������.

������ ������ ���� �������� "varlena" ������ (�.�., ������ ������ ����� �� ����� �������� �������, �� ������� ������� ������). ����� �������, ���������� ������������ ������������ ������, ��� ������������ ������. ������, ��� ���� ������ ����� ��������� ������ ��� ����� ���� ��������� �� � ������� ���� ����� TOAST, ��� ��� ���������� �������� ������������ ����� ����� ���� � ������, ��� ���������.

VARCHAR(n) - ��� ������ �������, ����� ����� ������� ������ ���������� �����, �� ����������� ������������� �������. TEXT - ��� ������ ������� ��� ����� �������������� �����, � ����������� ���������� ������ � 1 ��������.

CHAR(n) - ��� ������ ������� ��� �������� �����, ������� ������ ����� ���������� �����. CHAR(n) ����������� �������� �� �������� �����, � �� ����� ��� VARCHAR(n) ������ ������ �������, �� ������� ������� ������. BYTEA ������������ ��� �������� �������� ������, �������� ������� ����� �������� NULL �����. ��� ���� ��������� �����, ����� ������� �������������� ������������������.

4.15.1) ��� ��� ������� ���� serial/�-����-�����������?

PostgreSQL ������������ ��� ������ SERIAL. �� ������������� ������� ������������������ � ������ ��� �������. ��������:

    CREATE TABLE person ( 
        id   SERIAL, 
        name TEXT 
    );
������������� ������������� �:
    CREATE SEQUENCE person_id_seq;
    CREATE TABLE person ( 
        id   INT4 NOT NULL DEFAULT nextval('person_id_seq'),
        name TEXT 
    );
    CREATE UNIQUE INDEX person_id_key ON person ( id );
�������� ����������� � ������������������� �� �������� ����������� ����������� create_sequence. �� ����� ������ ������������ ������ ���� OID � ������ ��� ���������� ��������. ������, ���� ��� ����� ���� � ������������ ���� ������, ��� ���������� ������������ ������� pg_dump � ������ -o ��� ����� COPY WITH OIDS ��� ���������� �������� ���� OID.

4.15.2) ��� ��� �������� �������� ��� ������� SERIAL?

���� �� �������� ������� � ��������� ���������� �������� SERIAL �� ������� sequence � ������� ������� nextval() ����� �������� � ����� ��������� ��� �������� ����. ����������� �������-������ � 4.15.1, ������ � ����������� ������� ��� ��� ��������:

    new_id = execute("SELECT nextval('person_id_seq')");
    execute("INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal')");
����� �� ������ ����� ��������� ����� �������� � ���������� new_id ��� ��� ������������� � ������ �������� (�������� ����� ��� ������� ���� ��� ������� person). �������, ��� ��� ������������� ���������� ������� SEQUENCE ����� <table>_<serialcolumn>_seq, ��� tableserialcolumn �������� �������������� ������� ����� ������� � ����� ������� SERIAL.

� �������� ������������, �� ������ �������� ����������� �������� SERIAL � ������� ������� currval() ����� ���������� ������� �������� �������, ��������

    execute("INSERT INTO person (name) VALUES ('Blaise Pascal')");
    new_id = execute("SELECT currval('person_id_seq')");
� �������, �� ������ ������������ �������� OID, ����������� �� �������� INSERT ����� ������� �������� �� ���������, ��� ���������������� �������� �������� ����������� �� ������ ��������� ��������. � Perl, ��������� DBI � ������� Edmund Mergl'� DBD::Pg, �������� oid ���������� ��������� ����� $sth->{pg_oid_status} ����� $sth->execute().

4.15.3) �� ����� �� ���������� ���, ��� ������������� currval()nextval() �������� � �������������� � ������� ��������������?

���. currval() ���������� ������� ��������, ����������� ����� backend'��, � �� ������� ��������������.

4.15.4) ������ ����� �� ���� ������������������ �� ������������ ����� ��� ������ ����������? ������ ��������� ������� ��� ��������� � �������, ��� � ��������� ������������������/SERIAL?

��� ���������� �������������, �������� �������������������, ��� ������������� �������� �� ����� ������� ���������� � �� ����������� �� ������� ���������� ����������. ��� ����� �������� ������� � ��������� ��� ������ ����������.

4.16) ��� ����� OID? ��� ����� TID?

���� OID ������ ����������� ��������������� ������� � PostgreSQL. ������ ������, ������� ��������� � PostgreSQL �������� ���������� OID. ��� �������� OID ������������ �� ����� initdb ����� �������� ������ 16384 (�� include/access/transam.h). ��� ��������� ������������� OID ����� ������� ��������. �� ���������, ��� ��� OID �������� ����������� �� ������ ������ �����-���� ������� ��� ���� ������, �� � ������ ���� ���� PostgreSQL.

PostgreSQL ���������� OID � ����� ���������� ��������� �������� ��� ����� ������� � ������. �������� OID ����� ���� ������������ ��� ������������� �������� ������������� �������, � ����� �������������� ��� �����������. ������������� ������������ ��� ������� OID ��� �������� �������� OID �� ������ ������� ������ �� ���� OID ��� ����� �������� �������.

�������� OID ����������� ��� ���� ����� ������� �� ����������� �������, ������� ������������ ����� ����� ������ ������. ���� �� ������ �������� OID �� �����-���� ������ �������� ��� ���� �� ������ ������� ����� ������� � �������� OID, �� ��� ����� ������� ���:

        CREATE TABLE new_table(old_oid oid, mycol int);
        SELECT old_oid, mycol INTO new FROM old;
        COPY new TO '/tmp/pgtable';
        DELETE FROM new;
        COPY new WITH OIDS FROM '/tmp/pgtable';

OID �������� ��� 4-� ������� ����� � �� ����� ��������� �������� � 4 ���������. ������, ��� ����� �� ������� � ���, ��� ����� ���������, �� �� ��������� �� ���� ��� ��� ��������� ��������� �� ����� �����������.

TID ������������ ��� ������������� ����������� ���������� ������� � �������� � offset ����������. TID ���������� ����� ���� ��� ������ ���� �������� ��� �����������.

TID ������������ ���������� �������� � �������� ��������� �� ���������� ������.

4.17) ��� �������� ��������� ������� ������������ � PostgreSQL?

��������� �������� ��� � ������ ������������ ���������� ������������������� �������. ��� ��������� �� ���:

������ ����� �������� �� ����� ������ ����� ����� �� http://hea-www.harvard.edu/MST/simul/software/docs/pkgs/pgsql/glossary/glossary.html

4.18) ������ � ������� ������ "ERROR: Memory exhausted in AllocSetAlloc()"?

���������������� � ��� ����������� ����������� ������ ��� ��� ���� ���� ����� ��������� ����� �� ������������ �������. ����������� ����� �������� postmaster ��������� ��������� �������:

    ulimit -d 262144
    limit datasize 256m
� ����������� �� ���������� �������������� shell, ������ ���� �� ������ ������ ���������� �������, �� ��� �������� ��� ���������� ������� ������� ������ �������� � �������� ����� ��������. ��� ������� �������� ��������� �������� �������� � ���� ��� ��������, ��������� ����� ţ �������. ���� � ��� �������� �������� � SQL ��������, ������ ��� backend ���������� ������� ������� ����� ������, ����������� ��������� ��� ������� ����� �������� �������.

4.19) ��� ��� ������, ����� ������ PostgreSQL ��������?

�� psql, �������� SELECT version();

4.20) ������ ��� ������ � ���� ������� �������� � ������� ������ "invalid large obj descriptor"?

��� ����� ��� ������������� �������� ������� ��������� � ������ BEGIN WORK � � ����� COMMIT, � ������ ������������� ����� lo_open ... lo_close.

� ��������� ������ PostgreSQL �������, ����� ��� �������� �������� ������� ����������� ���������� ����������. ����� �������, ������ �� ������� ������� ���-���� � ������� ��������, �� �������� ������� ������� �������� � ��������� invalid large obj descriptor, ��� ��� ��� ����������� ������ ��� ������� �������� (�� ������� ���� � ��������� ������) ����� ������������ ��������� �� ������ ���� �� �� ����������� ����������.

���� �� ����������� ����� ��������� ������� ��� ODBC, ��� �������� ����������� ���������� auto-commit off.

4.21) ��� ��� ������� ������� ������� �� ��������� ����� ��������� ������� �����?

����������� CURRENT_TIMESTAMP:

CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );

4.22) ������ ��� ����������, ������������ IN ��� �������� ���������?

� ��������� ������, �� ��������� ��������� ��� ������� �������� ����� ���������������� ������� ���������� ���������� ��� ������ ������ �������� �������. ���� ��������� ���������� ������ ��������� ������� � ������� ������ ���������� ����� �������, IN �������� �������� ������. ����� ��������� �������� � ������ ��������, �������� IN �� EXISTS:

    SELECT *
    FROM tab
    WHERE col IN (SELECT subcol FROM subtab);
��:
    SELECT *
    FROM tab
    WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col);
����� ����� ����������� �������� ������, ������� subcol ������ ���� ����������������. ��� �������� ������������������ ����� ��������� � ������ 7.4.

4.23) ��� ��� ��������� ������� ����������?

PostgreSQL ������������ ������� ����������, ��������� ����������� ��������� SQL. ��� ��� �������:

    SELECT *
    FROM t1 LEFT OUTER JOIN t2 ON (t1.col = t2.col);
���
    SELECT *
    FROM t1 LEFT OUTER JOIN t2 USING (col);

��� ���������� ������� ���������� t1.col � t2.col, ����� ���������� ����� ����������� ������ � t1 (������� �� ��������� � t2). RIGHT ���������� ������ �������� ����������� ������ t2. FULL ���������� ������ ���������� ��������� ������ ���� ��� ����������� ������ �� t1 � t2. ����� OUTER �������� �������������� � ����������� � LEFT, RIGHTFULL �����������. ������� ���������� ���������� INNER ����������.

� ���������� �������, ������� ���������� ����� ���� ����������� ��������� UNIONNOT IN. ��������, ����� ���������� ���������� tab1tab2, ��������� ������ ��������� ������� ���������� ���� ������:

    SELECT tab1.col1, tab2.col2
    FROM tab1, tab2
    WHERE tab1.col1 = tab2.col1
    UNION ALL
    SELECT tab1.col1, NULL
    FROM tab1
    WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
    ORDER BY col1

4.24) ��� ��������� �������, ������������ ��������� ��� ������?

�� ���������� ������� ������� ������ � ����� ������ �������� �� �������. ��������� PostgreSQL ��������� ��������� �������� ����������� ��� ���� ������, ��������� ����, ��� ������ ���� ����� ����� ���������� ������.

contrib/dblink ��������� ������� ����� ������, ��������� ������ �������. ����������, ������ ����� ������������ ������������� ����������� � ���������� ������ ������ � ����� ������� ���������� ���������� �� ���.

4.25) ��� ��� ������� �� ������� ��������� �������?

� ������ 7.3, �� ������ ����� ������� ��������� ������� ��� ������� �� �����-���� �������, http://techdocs.postgresql.org/guides/SetReturningFunctions.

4.26) ������ � �� ���� ������� ���������/������� ��������� ������� � �������� PL/PgSQL?

PL/PgSQL �������� ���������� ������� � ���� �� ���������� �������� ����� ������� � ���, ��� ���� ������� PL/PgSQL ���������� � ��������� ������� � ��� ������� ������� ��������� � �������������, � ������� ����� ���������� �����, �� �� ����� �������� � ������, ������ ��� ������������� ���������� ������� �������� ��������� �� ������ ��������� �������. ����� ������ ��� ��������, ����������� EXECUTE ��� ������� � ��������� �������� � PL/PgSQL. ������������� ����� ��������� �������� ������ ������������������ ������ ���.

4.27) ����� ����� ���������� ����������?

���� ��������� ����� ��� ���������� ���� master/slave. ��� ��������� ������������� ������ master ������� ��� �������� ��������� � ���� ������, � slave ������� ������ ��������� ������ ������ �� ����. �� ���� ������� �����: http://gborg.PostgreSQL.org/genpage?replication_research. � ���������� � ����������� master ��������� ������� �����: http://gborg.PostgreSQL.org/project/pgreplication/projdisplay.php.

4.28) ����� ����� ���������� ����������?


���������� PostgreSQL

5.1) � ������� ������� ������������ �������������. ����� � �������� �� � psql, ������ � ������� dump core?

�������� ����� ����������� � ���������� �����. ����������� ������ �������������� ���� ������� � ��������� ��������������� ���������.

5.2) ��� � ���� ������ ��������� �������� ����� ���� � ������� � PostgreSQL?

��������� ���� ���������� � ������ �������� pgsql-hackers � ��� �� ����������� ����� �������� � ���������� contrib/.

5.3) ��� ��� �������� C �������, ������������ ������?

� ������� PostgreSQL, ������� � 7.3, �������, ������������ ������� ��������� �������������� � C, PL/PgSQL � SQL. ����������� �������� � ����������� ������������. ������ ������������ ������� �������, ���������� �� C, ����� ����� � contrib/tablefunc.

5.4) � ������� �������� ����. ������ ����� �������������� � �� ���� ���������?

����� Makefile �� ����� ���������� ������������ ��� include ������. �� ������ ��������� make clean � ����� make. ���� �� ����������� GCC �� ������ ������������ ����� --enable-dependconfigure ����� �������� ����������� ������������� ����������� �����������.