From 0896707ef612d69263838551ee9af526235f50dd Mon Sep 17 00:00:00 2001
From: Bruce Momjian Last updated: Fri Oct 11 13:54:56 EDT 2002 Last updated: Sun Oct 13 22:49:56 EDT 2002 Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) The most recent version of this document can be viewed at http://www.PostgreSQL.org/docs/faq-english.html.Frequently Asked Questions (FAQ) for PostgreSQL
-
@@ -22,15 +22,14 @@
Platform-specific questions are answered at http://www.PostgreSQL.org/users-lounge/docs/faq.html.
PostgreSQL is pronounced Post-Gres-Q-L.
@@ -172,12 +171,12 @@ extended subset of SQL. PostgreSQL is free and the complete source is available. -PostgreSQL development is performed by a team of Internet +
PostgreSQL development is performed by a team of developers who all subscribe to the PostgreSQL development mailing list. The current coordinator is Marc G. Fournier (scrappy@PostgreSQL.org). (See - below on how to join). This team is now responsible for all - development of PostgreSQL.
+ section 1.6 on how to join). This team is now + responsible for all development of PostgreSQL.The authors of PostgreSQL 1.01 were Andrew Yu and Jolly Chen. Many others have contributed to the porting, testing, debugging, @@ -239,10 +238,10 @@
Client
It is possible to compile the libpq C library, psql, and - other interfaces and binaries to run on MS Windows platforms. In - this case, the client is running on MS Windows, and communicates + other interfaces and client applications to run on MS Windows platforms. + In this case, the client is running on MS Windows, and communicates via TCP/IP to a server running on one of our supported Unix - platforms. A file win31.mak is included in the distribution + platforms. A file win32.mak is included in the distribution for making a Win32 libpq library and psql. PostgreSQL also communicates with ODBC clients.
@@ -250,10 +249,11 @@The database server can run on Windows NT and Win2k using Cygwin, the Cygnus Unix/NT porting library. See - pgsql/doc/FAQ_MSWIN in the distribution or the MS Windows FAQ - on our web site. We have no plan to do a native port to any - Microsoft platform.
+ pgsql/doc/FAQ_MSWIN in the distribution or the MS Windows FAQ + at http://www.PostgreSQL.org/docs/faq-mswin.html. + +A native port to some Microsoft platforms is currently being worked + upon.
A list of commercial support companies is available at http://www.postgresql.org/users-lounge/commercial-support.html.
+ "http://www.PostgreSQL.org/users-lounge/commercial-support.html">http://www.PostgreSQL.org/users-lounge/commercial-support.html.psql has some nice \d commands to show information about types, operators, functions, aggregates, etc.
@@ -402,10 +402,10 @@Please visit the PostgreSQL BugTool - page, which gives guidelines and directions on how to submit a - bug.
+Please visit the PostgreSQL BugTool page at http://www.PostgreSQL.org/bugs/bugs.php, + which gives guidelines and directions on how to submit a + bug report.
Also check out our ftp site ftp://ftp.PostgreSQL.org/pub to @@ -460,14 +460,14 @@
PostgreSQL has had a first-class infrastructure since we started - six years ago. This is all thanks to Marc Fournier, who has created + in 1994. This is all thanks to Marc Fournier, who has created and managed this infrastructure over the years.
Quality infrastructure is very important to an open-source @@ -494,9 +494,7 @@
Of course, this infrastructure is not cheap. There are a variety of monthly and one-time expenses that are required to keep it going. If you or your company has money it can donate to help fund - this effort, please go to - https://store.pgsql.com/shopping/index.php?id=1 + this effort, please go to http://store.pgsql.com/shopping/ and make a donation.
Although the web page mentions PostgreSQL, Inc, the @@ -538,28 +536,23 @@
A nice introduction to Database-backed Web pages can be seen at: http://www.webreview.com
-There is also one at http://www.phone.net/home/mwm/hotlist/.
-For Web integration, PHP is an excellent interface. It is at http://www.php.net.
-For complex cases, many use the Perl interface and CGI.pm.
+For complex cases, many use the Perl interface and CGI.pm or mod_perl.
We have a nice graphical user interface called pgaccess, - which is shipped as part of the distribution. pgaccess also - has a report generator. The Web page is http://www.flex.ro/pgaccess
+We have a nice graphical user interface called PgAccess, which is + shipped as part of the distribution. PgAccess also has a report + generator. The Web page is http://www.pgaccess.org/.
We also include ecpg, which is an embedded SQL query language interface for C.
-We have:
@@ -572,7 +565,7 @@Additional interfaces are available at - http://www.postgresql.org/interfaces.html. +
Additional interfaces are available at + http://www.PostgreSQL.org/interfaces.html.
They are temporary files generated by the query executor. For @@ -793,16 +784,16 @@
The PostgreSQL team makes only small changes between minor releases, so upgrading from 7.2 to 7.2.1 does not require a dump and restore. - However, major releases often change the internal format of system - tables and data files. These changes are often complex, so we don't - maintain backward compatability for data files. A dump outputs data - in a generic format that can then be loaded in using the new internal - format. + However, major releases (e.g. from 7.2 to 7.3) often change the internal + format of system tables and data files. These changes are often complex, + so we don't maintain backward compatability for data files. A dump outputs + data in a generic format that can then be loaded in using the new internal + format.
-In releases where the on-disk format does not change, the +
In releases where the on-disk format does not change, the pg_upgrade script can be used to upgrade without a dump/restore. The release notes mention whether pg_upgrade is available for the - release. + release.
The entire query may have to be evaluated, even if you only want
- the first few rows. Consider a query that has an ORDER
+ the first few rows. Consider using a query that has an ORDER
BY. If there is an index that matches the ORDER
BY, PostgreSQL may be able to evaluate only the first few
records requested, or the entire query may have to be evaluated
@@ -840,8 +831,8 @@
4.4) How do you remove a column from a
table?
-
We do not support ALTER TABLE DROP COLUMN, but do - this:
+Prior to version 7.3, ALTER TABLE DROP COLUMN is not supported. + You can do this instead:
BEGIN; LOCK TABLE old_table; @@ -892,7 +883,7 @@ be estimated as 6.4 MB:36 bytes: each row header (approximate) - 24 bytes: one int field and one text filed + 24 bytes: one int field and one text field + 4 bytes: pointer on page to tuple ---------------------------------------- 64 bytes per row @@ -957,7 +948,7 @@ SELECT col FROM tab ORDER BY col [ DESC ] - LIMIT 1 + LIMIT 1;When using wild-card operators such as LIKE or @@ -972,10 +963,10 @@
@@ -1032,13 +1023,13 @@
SELECT * FROM tab - WHERE lower(col) = 'abc' + WHERE LOWER(col) = 'abc';This will not use an standard index. However, if you create a functional index, it will be used:
- CREATE INDEX tabindex on tab (lower(col)); + CREATE INDEX tabindex ON tab (LOWER(col));
CHAR() is best when storing strings that are - usually the same length. VARCHAR() is best when +
CHAR(n) is best when storing strings that are + usually the same length. VARCHAR(n) is best when storing variable-length strings but it limits how long a string can be. TEXT is for strings of unlimited length, maximum 1 gigabyte. BYTEA is for storing binary data, @@ -1111,11 +1102,11 @@ BYTEA bytea variable-length byte array (null-byte safe)
One approach is to retrieve the next SERIAL value from the sequence object with the nextval() function before inserting and then insert it explicitly. Using the - example table in 4.15.1, that might look like - this in Perl:
+ example table in 4.15.1, an example in a + pseudo-language would look like this:- new_id = output of "SELECT nextval('person_id_seq')" - INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal'); + new_id = execute("SELECT nextval('person_id_seq')"); + execute("INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal')");You would then also have the new value stored in @@ -1124,14 +1115,14 @@ BYTEA bytea variable-length byte array (null-byte safe) automatically created SEQUENCE object will be named <table>_<serialcolumn>_seq, where table and serialcolumn are the names of your table - and your SERIAL column, respectively. + and your SERIAL column, respectively.
Alternatively, you could retrieve the assigned SERIAL value with the currval() function after it was inserted by default, e.g.,
- INSERT INTO person (name) VALUES ('Blaise Pascal'); - new_id = output of "SELECT currval('person_id_seq')"; + execute("INSERT INTO person (name) VALUES ('Blaise Pascal')"); + new_id = execute("SELECT currval('person_id_seq')");Finally, you could use the OID @@ -1139,12 +1130,12 @@ BYTEA bytea variable-length byte array (null-byte safe) default value, though this is probably the least portable approach. In Perl, using DBI with Edmund Mergl's DBD::Pg module, the oid value is made available via $sth->{pg_oid_status} after - $sth->execute(). + $sth->execute().
No. Currval() returns the current value assigned by your +
No. currval() returns the current value assigned by your backend, not by all users.
OIDs are stored as 4-byte integers, and will overflow at 4 billion. No one has reported this ever happening, and we plan to have the limit removed before anyone does.
@@ -1228,7 +1218,7 @@ BYTEA bytea variable-length byte array (null-byte safe)A list of general database terms can be found at: http://www.comptechnews.com/~reaster/dbdesign.html
+ "http://hea-www.harvard.edu/MST/simul/software/docs/pkgs/pgsql/glossary/glossary.html">http://hea-www.harvard.edu/MST/simul/software/docs/pkgs/pgsql/glossary/glossary.htmlFrom psql, type select version();
From psql, type SELECT version();
IN
is fastest. To
speed up other queries, replace IN
with
EXISTS
:
-
-SELECT *
+ SELECT *
FROM tab
- WHERE col IN (SELECT subcol FROM subtab)
-
+ WHERE col IN (SELECT subcol FROM subtab);
- to:
-
-SELECT *
+ to:
+ SELECT *
FROM tab
- WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col)
-
+ WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col);
For this to be fast, subcol
should be an indexed column.
- We hope to fix this limitation in a future release.
+ We hope to fix this limitation in a future release.
You can return result sets from PL/pgSQL functions using refcursors. See - http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html, + "http://www.PostgreSQL.org/idocs/index.php?plpgsql-cursors.html"> + http://www.PostgreSQL.org/idocs/index.php?plpgsql-cursors.html, section 23.7.3.3.
There are several master/slave replication options available. These allow only the master to make database changes and the slave can only do database reads. The bottom of - http://gborg.postgresql.org/genpage?replication_research lists + href="http://gborg.PostgreSQL.org/genpage?replication_research"> + http://gborg.PostgreSQL.org/genpage?replication_research lists them. A multi-master replication solution is being worked on at http://gborg.postgresql.org/project/pgreplication/projdisplay.php.
+ href="http://gborg.PostgreSQL.org/project/pgreplication/projdisplay.php">http://gborg.PostgreSQL.org/project/pgreplication/projdisplay.php. -