mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Remove FAQ item about binary cursors.
This commit is contained in:
parent
e136a49c5d
commit
97052bc9c9
123
doc/FAQ
123
doc/FAQ
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Frequently Asked Questions (FAQ) for PostgreSQL
|
Frequently Asked Questions (FAQ) for PostgreSQL
|
||||||
|
|
||||||
Last updated: Sat Jan 29 22:59:12 EST 2005
|
Last updated: Sat Jan 29 23:02:37 EST 2005
|
||||||
|
|
||||||
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
|
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
|
||||||
|
|
||||||
@ -49,43 +49,42 @@
|
|||||||
|
|
||||||
Operational Questions
|
Operational Questions
|
||||||
|
|
||||||
4.1) What is the difference between binary cursors and normal cursors?
|
4.1) How do I SELECT only the first few rows of a query? A random row?
|
||||||
4.2) How do I SELECT only the first few rows of a query? A random row?
|
4.2) How do I find out what tables, indexes, databases, and users are
|
||||||
4.3) How do I find out what tables, indexes, databases, and users are
|
|
||||||
defined? How do I see the queries used by psql to display them?
|
defined? How do I see the queries used by psql to display them?
|
||||||
4.4) How do you remove a column from a table, or change its data type?
|
4.3) How do you remove a column from a table, or change its data type?
|
||||||
4.5) What is the maximum size for a row, a table, and a database?
|
4.4) What is the maximum size for a row, a table, and a database?
|
||||||
4.6) How much database disk space is required to store data from a
|
4.5) How much database disk space is required to store data from a
|
||||||
typical text file?
|
typical text file?
|
||||||
4.7) My queries are slow or don't make use of the indexes. Why?
|
4.6) My queries are slow or don't make use of the indexes. Why?
|
||||||
4.8) How do I see how the query optimizer is evaluating my query?
|
4.7) How do I see how the query optimizer is evaluating my query?
|
||||||
4.9) What is an R-tree index?
|
4.8) What is an R-tree index?
|
||||||
4.10) What is the Genetic Query Optimizer?
|
4.9) What is the Genetic Query Optimizer?
|
||||||
4.11) How do I perform regular expression searches and
|
4.10) How do I perform regular expression searches and
|
||||||
case-insensitive regular expression searches? How do I use an index
|
case-insensitive regular expression searches? How do I use an index
|
||||||
for case-insensitive searches?
|
for case-insensitive searches?
|
||||||
4.12) In a query, how do I detect if a field is NULL?
|
4.11) In a query, how do I detect if a field is NULL?
|
||||||
4.13) What is the difference between the various character types?
|
4.12) What is the difference between the various character types?
|
||||||
4.14.0) How do I create a serial/auto-incrementing field?
|
4.13.0) How do I create a serial/auto-incrementing field?
|
||||||
4.14.1) How do I get the value of a SERIAL insert?
|
4.13.1) How do I get the value of a SERIAL insert?
|
||||||
4.14.2) Doesn't currval() lead to a race condition with other users?
|
4.13.2) Doesn't currval() lead to a race condition with other users?
|
||||||
4.14.3) Why aren't my sequence numbers reused on transaction abort?
|
4.13.3) Why aren't my sequence numbers reused on transaction abort?
|
||||||
Why are there gaps in the numbering of my sequence/SERIAL column?
|
Why are there gaps in the numbering of my sequence/SERIAL column?
|
||||||
4.15) What is an OID? What is a TID?
|
4.14) What is an OID? What is a TID?
|
||||||
4.16) What is the meaning of some of the terms used in PostgreSQL?
|
4.15) What is the meaning of some of the terms used in PostgreSQL?
|
||||||
4.17) Why do I get the error "ERROR: Memory exhausted in
|
4.16) Why do I get the error "ERROR: Memory exhausted in
|
||||||
AllocSetAlloc()"?
|
AllocSetAlloc()"?
|
||||||
4.18) How do I tell what PostgreSQL version I am running?
|
4.17) How do I tell what PostgreSQL version I am running?
|
||||||
4.19) Why does my large-object operations get "invalid large obj
|
4.18) Why does my large-object operations get "invalid large obj
|
||||||
descriptor"?
|
descriptor"?
|
||||||
4.20) How do I create a column that will default to the current time?
|
4.19) How do I create a column that will default to the current time?
|
||||||
4.21) Why are my subqueries using IN so slow?
|
4.20) Why are my subqueries using IN so slow?
|
||||||
4.22) How do I perform an outer join?
|
4.21) How do I perform an outer join?
|
||||||
4.23) How do I perform queries using multiple databases?
|
4.22) How do I perform queries using multiple databases?
|
||||||
4.24) How do I return multiple rows or columns from a function?
|
4.23) How do I return multiple rows or columns from a function?
|
||||||
4.25) Why can't I reliably create/drop temporary tables in PL/PgSQL
|
4.24) Why can't I reliably create/drop temporary tables in PL/PgSQL
|
||||||
functions?
|
functions?
|
||||||
4.26) What encryption options are available?
|
4.25) What encryption options are available?
|
||||||
|
|
||||||
Extending PostgreSQL
|
Extending PostgreSQL
|
||||||
|
|
||||||
@ -567,11 +566,7 @@ log_*
|
|||||||
|
|
||||||
Operational Questions
|
Operational Questions
|
||||||
|
|
||||||
4.1) What is the difference between binary cursors and normal cursors?
|
4.1) How do I SELECT only the first few rows of a query? A random row?
|
||||||
|
|
||||||
See the DECLARE manual page for a description.
|
|
||||||
|
|
||||||
4.2) How do I SELECT only the first few rows of a query? A random row?
|
|
||||||
|
|
||||||
See the FETCH manual page, or use SELECT ... LIMIT....
|
See the FETCH manual page, or use SELECT ... LIMIT....
|
||||||
|
|
||||||
@ -587,7 +582,7 @@ log_*
|
|||||||
ORDER BY random()
|
ORDER BY random()
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
4.3) How do I find out what tables, indexes, databases, and users are
|
4.2) How do I find out what tables, indexes, databases, and users are
|
||||||
defined? How do I see the queries used by psql to display them?
|
defined? How do I see the queries used by psql to display them?
|
||||||
|
|
||||||
Use the \dt command to see tables in psql. For a complete list of
|
Use the \dt command to see tables in psql. For a complete list of
|
||||||
@ -606,7 +601,7 @@ log_*
|
|||||||
many of the SELECTs needed to get information from the database system
|
many of the SELECTs needed to get information from the database system
|
||||||
tables.
|
tables.
|
||||||
|
|
||||||
4.4) How do you remove a column from a table, or change its data type?
|
4.3) How do you remove a column from a table, or change its data type?
|
||||||
|
|
||||||
DROP COLUMN functionality was added in release 7.3 with ALTER TABLE
|
DROP COLUMN functionality was added in release 7.3 with ALTER TABLE
|
||||||
DROP COLUMN. In earlier versions, you can do this:
|
DROP COLUMN. In earlier versions, you can do this:
|
||||||
@ -632,7 +627,7 @@ log_*
|
|||||||
You might then want to do VACUUM FULL tab to reclaim the disk space
|
You might then want to do VACUUM FULL tab to reclaim the disk space
|
||||||
used by the expired rows.
|
used by the expired rows.
|
||||||
|
|
||||||
4.5) What is the maximum size for a row, a table, and a database?
|
4.4) What is the maximum size for a row, a table, and a database?
|
||||||
|
|
||||||
These are the limits:
|
These are the limits:
|
||||||
Maximum size for a database? unlimited (32 TB databases exist)
|
Maximum size for a database? unlimited (32 TB databases exist)
|
||||||
@ -654,7 +649,7 @@ log_*
|
|||||||
The maximum table size and maximum number of columns can be quadrupled
|
The maximum table size and maximum number of columns can be quadrupled
|
||||||
by increasing the default block size to 32k.
|
by increasing the default block size to 32k.
|
||||||
|
|
||||||
4.6) How much database disk space is required to store data from a typical
|
4.5) How much database disk space is required to store data from a typical
|
||||||
text file?
|
text file?
|
||||||
|
|
||||||
A PostgreSQL database may require up to five times the disk space to
|
A PostgreSQL database may require up to five times the disk space to
|
||||||
@ -688,7 +683,7 @@ log_*
|
|||||||
|
|
||||||
NULLs are stored as bitmaps, so they use very little space.
|
NULLs are stored as bitmaps, so they use very little space.
|
||||||
|
|
||||||
4.7) My queries are slow or don't make use of the indexes. Why?
|
4.6) My queries are slow or don't make use of the indexes. Why?
|
||||||
|
|
||||||
Indexes are not automatically used by every query. Indexes are only
|
Indexes are not automatically used by every query. Indexes are only
|
||||||
used if the table is larger than a minimum size, and the query selects
|
used if the table is larger than a minimum size, and the query selects
|
||||||
@ -730,7 +725,7 @@ log_*
|
|||||||
[a-e].
|
[a-e].
|
||||||
* Case-insensitive searches such as ILIKE and ~* do not utilize
|
* Case-insensitive searches such as ILIKE and ~* do not utilize
|
||||||
indexes. Instead, use functional indexes, which are described in
|
indexes. Instead, use functional indexes, which are described in
|
||||||
section 4.11.
|
section 4.10.
|
||||||
* The default C locale must be used during initdb because it is not
|
* The default C locale must be used during initdb because it is not
|
||||||
possible to know the next-greater character in a non-C locale. You
|
possible to know the next-greater character in a non-C locale. You
|
||||||
can create a special
|
can create a special
|
||||||
@ -743,11 +738,11 @@ LIKE
|
|||||||
types exactly match the index's column types. This is particularly
|
types exactly match the index's column types. This is particularly
|
||||||
true of int2, int8, and numeric column indexes.
|
true of int2, int8, and numeric column indexes.
|
||||||
|
|
||||||
4.8) How do I see how the query optimizer is evaluating my query?
|
4.7) How do I see how the query optimizer is evaluating my query?
|
||||||
|
|
||||||
See the EXPLAIN manual page.
|
See the EXPLAIN manual page.
|
||||||
|
|
||||||
4.9) What is an R-tree index?
|
4.8) What is an R-tree index?
|
||||||
|
|
||||||
An R-tree index is used for indexing spatial data. A hash index can't
|
An R-tree index is used for indexing spatial data. A hash index can't
|
||||||
handle range searches. A B-tree index only handles range searches in a
|
handle range searches. A B-tree index only handles range searches in a
|
||||||
@ -770,13 +765,13 @@ LIKE
|
|||||||
extending R-trees requires a bit of work and we don't currently have
|
extending R-trees requires a bit of work and we don't currently have
|
||||||
any documentation on how to do it.
|
any documentation on how to do it.
|
||||||
|
|
||||||
4.10) What is the Genetic Query Optimizer?
|
4.9) What is the Genetic Query Optimizer?
|
||||||
|
|
||||||
The GEQO module speeds query optimization when joining many tables by
|
The GEQO module speeds query optimization when joining many tables by
|
||||||
means of a Genetic Algorithm (GA). It allows the handling of large
|
means of a Genetic Algorithm (GA). It allows the handling of large
|
||||||
join queries through nonexhaustive search.
|
join queries through nonexhaustive search.
|
||||||
|
|
||||||
4.11) How do I perform regular expression searches and case-insensitive
|
4.10) How do I perform regular expression searches and case-insensitive
|
||||||
regular expression searches? How do I use an index for case-insensitive
|
regular expression searches? How do I use an index for case-insensitive
|
||||||
searches?
|
searches?
|
||||||
|
|
||||||
@ -793,11 +788,11 @@ LIKE
|
|||||||
functional index, it will be used:
|
functional index, it will be used:
|
||||||
CREATE INDEX tabindex ON tab (lower(col));
|
CREATE INDEX tabindex ON tab (lower(col));
|
||||||
|
|
||||||
4.12) In a query, how do I detect if a field is NULL?
|
4.11) In a query, how do I detect if a field is NULL?
|
||||||
|
|
||||||
You test the column with IS NULL and IS NOT NULL.
|
You test the column with IS NULL and IS NOT NULL.
|
||||||
|
|
||||||
4.13) What is the difference between the various character types?
|
4.12) What is the difference between the various character types?
|
||||||
|
|
||||||
Type Internal Name Notes
|
Type Internal Name Notes
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
@ -825,7 +820,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
particularly values that include NULL bytes. All the types described
|
particularly values that include NULL bytes. All the types described
|
||||||
here have similar performance characteristics.
|
here have similar performance characteristics.
|
||||||
|
|
||||||
4.14.1) How do I create a serial/auto-incrementing field?
|
4.13.1) How do I create a serial/auto-incrementing field?
|
||||||
|
|
||||||
PostgreSQL supports a SERIAL data type. It auto-creates a sequence.
|
PostgreSQL supports a SERIAL data type. It auto-creates a sequence.
|
||||||
For example, this:
|
For example, this:
|
||||||
@ -846,11 +841,11 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
However, if you need to dump and reload the database, you need to use
|
However, if you need to dump and reload the database, you need to use
|
||||||
pg_dump's -o option or COPY WITH OIDS option to preserve the OIDs.
|
pg_dump's -o option or COPY WITH OIDS option to preserve the OIDs.
|
||||||
|
|
||||||
4.14.2) How do I get the value of a SERIAL insert?
|
4.13.2) How do I get the value of a SERIAL insert?
|
||||||
|
|
||||||
One approach is to retrieve the next SERIAL value from the sequence
|
One approach is to retrieve the next SERIAL value from the sequence
|
||||||
object with the nextval() function before inserting and then insert it
|
object with the nextval() function before inserting and then insert it
|
||||||
explicitly. Using the example table in 4.14.1, an example in a
|
explicitly. Using the example table in 4.13.1, an example in a
|
||||||
pseudo-language would look like this:
|
pseudo-language would look like this:
|
||||||
new_id = execute("SELECT nextval('person_id_seq')");
|
new_id = execute("SELECT nextval('person_id_seq')");
|
||||||
execute("INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal')");
|
execute("INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal')");
|
||||||
@ -872,19 +867,19 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
billion. In Perl, using DBI with the DBD::Pg module, the oid value is
|
billion. In Perl, using DBI with the DBD::Pg module, the oid value is
|
||||||
made available via $sth->{pg_oid_status} after $sth->execute().
|
made available via $sth->{pg_oid_status} after $sth->execute().
|
||||||
|
|
||||||
4.14.3) Doesn't currval() lead to a race condition with other users?
|
4.13.3) Doesn't currval() lead to a race condition with other users?
|
||||||
|
|
||||||
No. currval() returns the current value assigned by your backend, not
|
No. currval() returns the current value assigned by your backend, not
|
||||||
by all users.
|
by all users.
|
||||||
|
|
||||||
4.14.4) Why aren't my sequence numbers reused on transaction abort? Why are
|
4.13.4) Why aren't my sequence numbers reused on transaction abort? Why are
|
||||||
there gaps in the numbering of my sequence/SERIAL column?
|
there gaps in the numbering of my sequence/SERIAL column?
|
||||||
|
|
||||||
To improve concurrency, sequence values are given out to running
|
To improve concurrency, sequence values are given out to running
|
||||||
transactions as needed and are not locked until the transaction
|
transactions as needed and are not locked until the transaction
|
||||||
completes. This causes gaps in numbering from aborted transactions.
|
completes. This causes gaps in numbering from aborted transactions.
|
||||||
|
|
||||||
4.15) What is an OID? What is a TID?
|
4.14) What is an OID? What is a TID?
|
||||||
|
|
||||||
Every row that is created in PostgreSQL gets a unique OID unless
|
Every row that is created in PostgreSQL gets a unique OID unless
|
||||||
created WITHOUT OIDS. OIDs are autotomatically assigned unique 4-byte
|
created WITHOUT OIDS. OIDs are autotomatically assigned unique 4-byte
|
||||||
@ -901,7 +896,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
values. TIDs change after rows are modified or reloaded. They are used
|
values. TIDs change after rows are modified or reloaded. They are used
|
||||||
by index entries to point to physical rows.
|
by index entries to point to physical rows.
|
||||||
|
|
||||||
4.16) What is the meaning of some of the terms used in PostgreSQL?
|
4.15) What is the meaning of some of the terms used in PostgreSQL?
|
||||||
|
|
||||||
Some of the source code and older documentation use terms that have
|
Some of the source code and older documentation use terms that have
|
||||||
more common usage. Here are some:
|
more common usage. Here are some:
|
||||||
@ -919,7 +914,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
http://hea-www.harvard.edu/MST/simul/software/docs/pkgs/pgsql/glossary
|
http://hea-www.harvard.edu/MST/simul/software/docs/pkgs/pgsql/glossary
|
||||||
/glossary.html
|
/glossary.html
|
||||||
|
|
||||||
4.17) Why do I get the error "ERROR: Memory exhausted in AllocSetAlloc()"?
|
4.16) Why do I get the error "ERROR: Memory exhausted in AllocSetAlloc()"?
|
||||||
|
|
||||||
You probably have run out of virtual memory on your system, or your
|
You probably have run out of virtual memory on your system, or your
|
||||||
kernel has a low limit for certain resources. Try this before starting
|
kernel has a low limit for certain resources. Try this before starting
|
||||||
@ -934,11 +929,11 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
problem with the SQL client because the backend is returning too much
|
problem with the SQL client because the backend is returning too much
|
||||||
data, try it before starting the client.
|
data, try it before starting the client.
|
||||||
|
|
||||||
4.18) How do I tell what PostgreSQL version I am running?
|
4.17) How do I tell what PostgreSQL version I am running?
|
||||||
|
|
||||||
From psql, type SELECT version();
|
From psql, type SELECT version();
|
||||||
|
|
||||||
4.19) Why does my large-object operations get "invalid large obj
|
4.18) Why does my large-object operations get "invalid large obj
|
||||||
descriptor"?
|
descriptor"?
|
||||||
|
|
||||||
You need to put BEGIN WORK and COMMIT around any use of a large object
|
You need to put BEGIN WORK and COMMIT around any use of a large object
|
||||||
@ -953,12 +948,12 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
If you are using a client interface like ODBC you may need to set
|
If you are using a client interface like ODBC you may need to set
|
||||||
auto-commit off.
|
auto-commit off.
|
||||||
|
|
||||||
4.20) How do I create a column that will default to the current time?
|
4.19) How do I create a column that will default to the current time?
|
||||||
|
|
||||||
Use CURRENT_TIMESTAMP:
|
Use CURRENT_TIMESTAMP:
|
||||||
CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
||||||
|
|
||||||
4.21) Why are my subqueries using IN so slow?
|
4.20) Why are my subqueries using IN so slow?
|
||||||
|
|
||||||
In versions prior to 7.4, subqueries were joined to outer queries by
|
In versions prior to 7.4, subqueries were joined to outer queries by
|
||||||
sequentially scanning the result of the subquery for each row of the
|
sequentially scanning the result of the subquery for each row of the
|
||||||
@ -979,7 +974,7 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
|||||||
In version 7.4 and later, IN actually uses the same sophisticated join
|
In version 7.4 and later, IN actually uses the same sophisticated join
|
||||||
techniques as normal queries, and is prefered to using EXISTS.
|
techniques as normal queries, and is prefered to using EXISTS.
|
||||||
|
|
||||||
4.22) How do I perform an outer join?
|
4.21) How do I perform an outer join?
|
||||||
|
|
||||||
PostgreSQL supports outer joins using the SQL standard syntax. Here
|
PostgreSQL supports outer joins using the SQL standard syntax. Here
|
||||||
are two examples:
|
are two examples:
|
||||||
@ -1009,7 +1004,7 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
|||||||
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
|
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
|
||||||
ORDER BY col1
|
ORDER BY col1
|
||||||
|
|
||||||
4.23) How do I perform queries using multiple databases?
|
4.22) How do I perform queries using multiple databases?
|
||||||
|
|
||||||
There is no way to query a database other than the current one.
|
There is no way to query a database other than the current one.
|
||||||
Because PostgreSQL loads database-specific system catalogs, it is
|
Because PostgreSQL loads database-specific system catalogs, it is
|
||||||
@ -1019,12 +1014,12 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
|||||||
course, a client can make simultaneous connections to different
|
course, a client can make simultaneous connections to different
|
||||||
databases and merge the results on the client side.
|
databases and merge the results on the client side.
|
||||||
|
|
||||||
4.24) How do I return multiple rows or columns from a function?
|
4.23) How do I return multiple rows or columns from a function?
|
||||||
|
|
||||||
In 7.3, you can easily return multiple rows or columns from a
|
In 7.3, you can easily return multiple rows or columns from a
|
||||||
function, http://techdocs.postgresql.org/guides/SetReturningFunctions.
|
function, http://techdocs.postgresql.org/guides/SetReturningFunctions.
|
||||||
|
|
||||||
4.25) Why can't I reliably create/drop temporary tables in PL/PgSQL
|
4.24) Why can't I reliably create/drop temporary tables in PL/PgSQL
|
||||||
functions?
|
functions?
|
||||||
|
|
||||||
PL/PgSQL caches function contents, and an unfortunate side effect is
|
PL/PgSQL caches function contents, and an unfortunate side effect is
|
||||||
@ -1035,7 +1030,7 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
|||||||
table access in PL/PgSQL. This will cause the query to be reparsed
|
table access in PL/PgSQL. This will cause the query to be reparsed
|
||||||
every time.
|
every time.
|
||||||
|
|
||||||
4.26) What encryption options are available?
|
4.25) What encryption options are available?
|
||||||
|
|
||||||
* contrib/pgcrypto contains many encryption functions for use in SQL
|
* contrib/pgcrypto contains many encryption functions for use in SQL
|
||||||
queries.
|
queries.
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
alink="#0000ff">
|
alink="#0000ff">
|
||||||
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
|
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
|
||||||
|
|
||||||
<P>Last updated: Sat Jan 29 22:59:12 EST 2005</P>
|
<P>Last updated: Sat Jan 29 23:02:37 EST 2005</P>
|
||||||
|
|
||||||
<P>Current maintainer: Bruce Momjian (<A href=
|
<P>Current maintainer: Bruce Momjian (<A href=
|
||||||
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
|
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
|
||||||
@ -71,63 +71,61 @@
|
|||||||
|
|
||||||
|
|
||||||
<H2 align="center">Operational Questions</H2>
|
<H2 align="center">Operational Questions</H2>
|
||||||
<A href="#4.1">4.1</A>) What is the difference between binary
|
<A href="#4.1">4.1</A>) How do I <SMALL>SELECT</SMALL> only the
|
||||||
cursors and normal cursors?<BR>
|
|
||||||
<A href="#4.2">4.2</A>) How do I <SMALL>SELECT</SMALL> only the
|
|
||||||
first few rows of a query? A random row?<BR>
|
first few rows of a query? A random row?<BR>
|
||||||
<A href="#4.3">4.3</A>) How do I find out what tables, indexes,
|
<A href="#4.2">4.2</A>) How do I find out what tables, indexes,
|
||||||
databases, and users are defined? How do I see the queries used
|
databases, and users are defined? How do I see the queries used
|
||||||
by <I>psql</I> to display them?<BR>
|
by <I>psql</I> to display them?<BR>
|
||||||
<A href="#4.4">4.4</A>) How do you remove a column from a
|
<A href="#4.3">4.3</A>) How do you remove a column from a
|
||||||
table, or change its data type?<BR>
|
table, or change its data type?<BR>
|
||||||
<A href="#4.5">4.5</A>) What is the maximum size for a row, a
|
<A href="#4.4">4.4</A>) What is the maximum size for a row, a
|
||||||
table, and a database?<BR>
|
table, and a database?<BR>
|
||||||
<A href="#4.6">4.6</A>) How much database disk space is required
|
<A href="#4.5">4.5</A>) How much database disk space is required
|
||||||
to store data from a typical text file?<BR>
|
to store data from a typical text file?<BR>
|
||||||
<A href="#4.7">4.7</A>) My queries are slow or don't make use of
|
<A href="#4.6">4.6</A>) My queries are slow or don't make use of
|
||||||
the indexes. Why?<BR>
|
the indexes. Why?<BR>
|
||||||
<A href="#4.8">4.8</A>) How do I see how the query optimizer is
|
<A href="#4.7">4.7</A>) How do I see how the query optimizer is
|
||||||
evaluating my query?<BR>
|
evaluating my query?<BR>
|
||||||
<A href="#4.9">4.9</A>) What is an R-tree index?<BR>
|
<A href="#4.8">4.8</A>) What is an R-tree index?<BR>
|
||||||
<A href="#4.10">4.10</A>) What is the Genetic Query Optimizer?<BR>
|
<A href="#4.9">4.9</A>) What is the Genetic Query Optimizer?<BR>
|
||||||
<A href="#4.11">4.11</A>) How do I perform regular expression
|
<A href="#4.10">4.10</A>) How do I perform regular expression
|
||||||
searches and case-insensitive regular expression searches? How do I
|
searches and case-insensitive regular expression searches? How do I
|
||||||
use an index for case-insensitive searches?<BR>
|
use an index for case-insensitive searches?<BR>
|
||||||
<A href="#4.12">4.12</A>) In a query, how do I detect if a field
|
<A href="#4.11">4.11</A>) In a query, how do I detect if a field
|
||||||
is <SMALL>NULL</SMALL>?<BR>
|
is <SMALL>NULL</SMALL>?<BR>
|
||||||
<A href="#4.13">4.13</A>) What is the difference between the
|
<A href="#4.12">4.12</A>) What is the difference between the
|
||||||
various character types?<BR>
|
various character types?<BR>
|
||||||
<A href="#4.14.0">4.14.0</A>) How do I create a
|
<A href="#4.13.0">4.13.0</A>) How do I create a
|
||||||
serial/auto-incrementing field?<BR>
|
serial/auto-incrementing field?<BR>
|
||||||
<A href="#4.14.1">4.14.1</A>) How do I get the value of a
|
<A href="#4.13.1">4.13.1</A>) How do I get the value of a
|
||||||
<SMALL>SERIAL</SMALL> insert?<BR>
|
<SMALL>SERIAL</SMALL> insert?<BR>
|
||||||
<A href="#4.14.2">4.14.2</A>) Doesn't <I>currval()</I>
|
<A href="#4.13.2">4.13.2</A>) Doesn't <I>currval()</I>
|
||||||
lead to a race condition with other users?<BR>
|
lead to a race condition with other users?<BR>
|
||||||
<A href="#4.14.3">4.14.3</A>) Why aren't my sequence numbers
|
<A href="#4.13.3">4.13.3</A>) Why aren't my sequence numbers
|
||||||
reused on transaction abort? Why are there gaps in the numbering of
|
reused on transaction abort? Why are there gaps in the numbering of
|
||||||
my sequence/SERIAL column?<BR>
|
my sequence/SERIAL column?<BR>
|
||||||
<A href="#4.15">4.15</A>) What is an <SMALL>OID</SMALL>? What is a
|
<A href="#4.14">4.14</A>) What is an <SMALL>OID</SMALL>? What is a
|
||||||
<SMALL>TID</SMALL>?<BR>
|
<SMALL>TID</SMALL>?<BR>
|
||||||
<A href="#4.16">4.16</A>) What is the meaning of some of the terms
|
<A href="#4.15">4.15</A>) What is the meaning of some of the terms
|
||||||
used in PostgreSQL?<BR>
|
used in PostgreSQL?<BR>
|
||||||
<A href="#4.17">4.17</A>) Why do I get the error <I>"ERROR: Memory
|
<A href="#4.16">4.16</A>) Why do I get the error <I>"ERROR: Memory
|
||||||
exhausted in AllocSetAlloc()"</I>?<BR>
|
exhausted in AllocSetAlloc()"</I>?<BR>
|
||||||
<A href="#4.18">4.18</A>) How do I tell what PostgreSQL version I
|
<A href="#4.17">4.17</A>) How do I tell what PostgreSQL version I
|
||||||
am running?<BR>
|
am running?<BR>
|
||||||
<A href="#4.19">4.19</A>) Why does my large-object operations get
|
<A href="#4.18">4.18</A>) Why does my large-object operations get
|
||||||
<I>"invalid large obj descriptor"</I>?<BR>
|
<I>"invalid large obj descriptor"</I>?<BR>
|
||||||
<A href="#4.20">4.20</A>) How do I create a column that will
|
<A href="#4.19">4.19</A>) How do I create a column that will
|
||||||
default to the current time?<BR>
|
default to the current time?<BR>
|
||||||
<A href="#4.21">4.21</A>) Why are my subqueries using
|
<A href="#4.20">4.20</A>) Why are my subqueries using
|
||||||
<CODE><SMALL>IN</SMALL></CODE> so slow?<BR>
|
<CODE><SMALL>IN</SMALL></CODE> so slow?<BR>
|
||||||
<A href="#4.22">4.22</A>) How do I perform an outer join?<BR>
|
<A href="#4.21">4.21</A>) How do I perform an outer join?<BR>
|
||||||
<A href="#4.23">4.23</A>) How do I perform queries using multiple
|
<A href="#4.22">4.22</A>) How do I perform queries using multiple
|
||||||
databases?<BR>
|
databases?<BR>
|
||||||
<A href="#4.24">4.24</A>) How do I return multiple rows or columns
|
<A href="#4.23">4.23</A>) How do I return multiple rows or columns
|
||||||
from a function?<BR>
|
from a function?<BR>
|
||||||
<A href="#4.25">4.25</A>) Why can't I reliably create/drop
|
<A href="#4.24">4.24</A>) Why can't I reliably create/drop
|
||||||
temporary tables in PL/PgSQL functions?<BR>
|
temporary tables in PL/PgSQL functions?<BR>
|
||||||
<A href="#4.26">4.26</A>) What encryption options are available?<BR>
|
<A href="#4.25">4.25</A>) What encryption options are available?<BR>
|
||||||
|
|
||||||
|
|
||||||
<H2 align="center">Extending PostgreSQL</H2>
|
<H2 align="center">Extending PostgreSQL</H2>
|
||||||
@ -712,13 +710,7 @@
|
|||||||
|
|
||||||
<H2 align="center">Operational Questions</H2>
|
<H2 align="center">Operational Questions</H2>
|
||||||
|
|
||||||
<H4><A name="4.1">4.1</A>) What is the difference between binary
|
<H4><A name="4.1">4.1</A>) How do I <SMALL>SELECT</SMALL> only the
|
||||||
cursors and normal cursors?</H4>
|
|
||||||
|
|
||||||
<P>See the <SMALL>DECLARE</SMALL> manual page for a
|
|
||||||
description.</P>
|
|
||||||
|
|
||||||
<H4><A name="4.2">4.2</A>) How do I <SMALL>SELECT</SMALL> only the
|
|
||||||
first few rows of a query? A random row?</H4>
|
first few rows of a query? A random row?</H4>
|
||||||
|
|
||||||
<P>See the <SMALL>FETCH</SMALL> manual page, or use
|
<P>See the <SMALL>FETCH</SMALL> manual page, or use
|
||||||
@ -739,7 +731,7 @@
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
<H4><A name="4.3">4.3</A>) How do I find out what tables, indexes,
|
<H4><A name="4.2">4.2</A>) How do I find out what tables, indexes,
|
||||||
databases, and users are defined? How do I see the queries used
|
databases, and users are defined? How do I see the queries used
|
||||||
by <I>psql</I> to display them?</H4>
|
by <I>psql</I> to display them?</H4>
|
||||||
|
|
||||||
@ -760,7 +752,7 @@
|
|||||||
illustrates many of the <SMALL>SELECT</SMALL>s needed to get
|
illustrates many of the <SMALL>SELECT</SMALL>s needed to get
|
||||||
information from the database system tables.</P>
|
information from the database system tables.</P>
|
||||||
|
|
||||||
<H4><A name="4.4">4.4</A>) How do you remove a column from a
|
<H4><A name="4.3">4.3</A>) How do you remove a column from a
|
||||||
table, or change its data type?</H4>
|
table, or change its data type?</H4>
|
||||||
|
|
||||||
<P><SMALL>DROP COLUMN</SMALL> functionality was added in release 7.3
|
<P><SMALL>DROP COLUMN</SMALL> functionality was added in release 7.3
|
||||||
@ -791,7 +783,7 @@
|
|||||||
<P>You might then want to do <I>VACUUM FULL tab</I> to reclaim the
|
<P>You might then want to do <I>VACUUM FULL tab</I> to reclaim the
|
||||||
disk space used by the expired rows.</P>
|
disk space used by the expired rows.</P>
|
||||||
|
|
||||||
<H4><A name="4.5">4.5</A>) What is the maximum size for a row, a
|
<H4><A name="4.4">4.4</A>) What is the maximum size for a row, a
|
||||||
table, and a database?</H4>
|
table, and a database?</H4>
|
||||||
|
|
||||||
<P>These are the limits:</P>
|
<P>These are the limits:</P>
|
||||||
@ -817,7 +809,7 @@
|
|||||||
<P>The maximum table size and maximum number of columns can be
|
<P>The maximum table size and maximum number of columns can be
|
||||||
quadrupled by increasing the default block size to 32k.</P>
|
quadrupled by increasing the default block size to 32k.</P>
|
||||||
|
|
||||||
<H4><A name="4.6">4.6</A>) How much database disk space is required
|
<H4><A name="4.5">4.5</A>) How much database disk space is required
|
||||||
to store data from a typical text file?</H4>
|
to store data from a typical text file?</H4>
|
||||||
|
|
||||||
<P>A PostgreSQL database may require up to five times the disk
|
<P>A PostgreSQL database may require up to five times the disk
|
||||||
@ -854,7 +846,7 @@
|
|||||||
<P><SMALL>NULL</SMALL>s are stored as bitmaps, so they
|
<P><SMALL>NULL</SMALL>s are stored as bitmaps, so they
|
||||||
use very little space.</P>
|
use very little space.</P>
|
||||||
|
|
||||||
<H4><A name="4.7">4.7</A>) My queries are slow or don't make use of
|
<H4><A name="4.6">4.6</A>) My queries are slow or don't make use of
|
||||||
the indexes. Why?</H4>
|
the indexes. Why?</H4>
|
||||||
|
|
||||||
<P>Indexes are not automatically used by every query. Indexes are only
|
<P>Indexes are not automatically used by every query. Indexes are only
|
||||||
@ -905,7 +897,7 @@
|
|||||||
e.g. [a-e].</LI>
|
e.g. [a-e].</LI>
|
||||||
<LI>Case-insensitive searches such as <SMALL>ILIKE</SMALL> and
|
<LI>Case-insensitive searches such as <SMALL>ILIKE</SMALL> and
|
||||||
<I>~*</I> do not utilize indexes. Instead, use functional
|
<I>~*</I> do not utilize indexes. Instead, use functional
|
||||||
indexes, which are described in section <a href="#4.11">4.11</a>.</LI>
|
indexes, which are described in section <a href="#4.10">4.10</a>.</LI>
|
||||||
<LI>The default <I>C</I> locale must be used during
|
<LI>The default <I>C</I> locale must be used during
|
||||||
<i>initdb</i> because it is not possible to know the next-greater
|
<i>initdb</i> because it is not possible to know the next-greater
|
||||||
character in a non-C locale. You can create a special
|
character in a non-C locale. You can create a special
|
||||||
@ -918,12 +910,12 @@
|
|||||||
types exactly match the index's column types. This is particularly
|
types exactly match the index's column types. This is particularly
|
||||||
true of int2, int8, and numeric column indexes.</P>
|
true of int2, int8, and numeric column indexes.</P>
|
||||||
|
|
||||||
<H4><A name="4.8">4.8</A>) How do I see how the query optimizer is
|
<H4><A name="4.7">4.7</A>) How do I see how the query optimizer is
|
||||||
evaluating my query?</H4>
|
evaluating my query?</H4>
|
||||||
|
|
||||||
<P>See the <SMALL>EXPLAIN</SMALL> manual page.</P>
|
<P>See the <SMALL>EXPLAIN</SMALL> manual page.</P>
|
||||||
|
|
||||||
<H4><A name="4.9">4.9</A>) What is an R-tree index?</H4>
|
<H4><A name="4.8">4.8</A>) What is an R-tree index?</H4>
|
||||||
|
|
||||||
<P>An R-tree index is used for indexing spatial data. A hash index
|
<P>An R-tree index is used for indexing spatial data. A hash index
|
||||||
can't handle range searches. A B-tree index only handles range
|
can't handle range searches. A B-tree index only handles range
|
||||||
@ -948,7 +940,7 @@
|
|||||||
practice, extending R-trees requires a bit of work and we don't
|
practice, extending R-trees requires a bit of work and we don't
|
||||||
currently have any documentation on how to do it.</P>
|
currently have any documentation on how to do it.</P>
|
||||||
|
|
||||||
<H4><A name="4.10">4.10</A>) What is the Genetic Query
|
<H4><A name="4.9">4.9</A>) What is the Genetic Query
|
||||||
Optimizer?</H4>
|
Optimizer?</H4>
|
||||||
|
|
||||||
<P>The <SMALL>GEQO</SMALL> module speeds query optimization when
|
<P>The <SMALL>GEQO</SMALL> module speeds query optimization when
|
||||||
@ -956,7 +948,7 @@
|
|||||||
the handling of large join queries through nonexhaustive
|
the handling of large join queries through nonexhaustive
|
||||||
search.</P>
|
search.</P>
|
||||||
|
|
||||||
<H4><A name="4.11">4.11</A>) How do I perform regular expression
|
<H4><A name="4.10">4.10</A>) How do I perform regular expression
|
||||||
searches and case-insensitive regular expression searches? How do I
|
searches and case-insensitive regular expression searches? How do I
|
||||||
use an index for case-insensitive searches?</H4>
|
use an index for case-insensitive searches?</H4>
|
||||||
|
|
||||||
@ -979,13 +971,13 @@
|
|||||||
CREATE INDEX tabindex ON tab (lower(col));
|
CREATE INDEX tabindex ON tab (lower(col));
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
<H4><A name="4.12">4.12</A>) In a query, how do I detect if a field
|
<H4><A name="4.11">4.11</A>) In a query, how do I detect if a field
|
||||||
is <SMALL>NULL</SMALL>?</H4>
|
is <SMALL>NULL</SMALL>?</H4>
|
||||||
|
|
||||||
<P>You test the column with <SMALL>IS NULL</SMALL> and <SMALL>IS
|
<P>You test the column with <SMALL>IS NULL</SMALL> and <SMALL>IS
|
||||||
NOT NULL</SMALL>.</P>
|
NOT NULL</SMALL>.</P>
|
||||||
|
|
||||||
<H4><A name="4.13">4.13</A>) What is the difference between the
|
<H4><A name="4.12">4.12</A>) What is the difference between the
|
||||||
various character types?</H4>
|
various character types?</H4>
|
||||||
<PRE>
|
<PRE>
|
||||||
Type Internal Name Notes
|
Type Internal Name Notes
|
||||||
@ -1017,7 +1009,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
particularly values that include <SMALL>NULL</SMALL> bytes. All the
|
particularly values that include <SMALL>NULL</SMALL> bytes. All the
|
||||||
types described here have similar performance characteristics.</P>
|
types described here have similar performance characteristics.</P>
|
||||||
|
|
||||||
<H4><A name="4.14.1">4.14.1</A>) How do I create a
|
<H4><A name="4.13.1">4.13.1</A>) How do I create a
|
||||||
serial/auto-incrementing field?</H4>
|
serial/auto-incrementing field?</H4>
|
||||||
|
|
||||||
<P>PostgreSQL supports a <SMALL>SERIAL</SMALL> data type. It
|
<P>PostgreSQL supports a <SMALL>SERIAL</SMALL> data type. It
|
||||||
@ -1045,13 +1037,13 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
you need to use <I>pg_dump</I>'s <I>-o</I> option or <SMALL>COPY
|
you need to use <I>pg_dump</I>'s <I>-o</I> option or <SMALL>COPY
|
||||||
WITH OIDS</SMALL> option to preserve the <SMALL>OID</SMALL>s.
|
WITH OIDS</SMALL> option to preserve the <SMALL>OID</SMALL>s.
|
||||||
|
|
||||||
<H4><A name="4.14.2">4.14.2</A>) How do I get the value of a
|
<H4><A name="4.13.2">4.13.2</A>) How do I get the value of a
|
||||||
<SMALL>SERIAL</SMALL> insert?</H4>
|
<SMALL>SERIAL</SMALL> insert?</H4>
|
||||||
|
|
||||||
<P>One approach is to retrieve the next <SMALL>SERIAL</SMALL> value
|
<P>One approach is to retrieve the next <SMALL>SERIAL</SMALL> value
|
||||||
from the sequence object with the <I>nextval()</I> function
|
from the sequence object with the <I>nextval()</I> function
|
||||||
<I>before</I> inserting and then insert it explicitly. Using the
|
<I>before</I> inserting and then insert it explicitly. Using the
|
||||||
example table in <A href="#4.14.1">4.14.1</A>, an example in a
|
example table in <A href="#4.13.1">4.13.1</A>, an example in a
|
||||||
pseudo-language would look like this:</P>
|
pseudo-language would look like this:</P>
|
||||||
<PRE>
|
<PRE>
|
||||||
new_id = execute("SELECT nextval('person_id_seq')");
|
new_id = execute("SELECT nextval('person_id_seq')");
|
||||||
@ -1074,7 +1066,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
new_id = execute("SELECT currval('person_id_seq')");
|
new_id = execute("SELECT currval('person_id_seq')");
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
<P>Finally, you could use the <A href="#4.15"><SMALL>OID</SMALL></A>
|
<P>Finally, you could use the <A href="#4.14"><SMALL>OID</SMALL></A>
|
||||||
returned from the <SMALL>INSERT</SMALL> statement to look up the
|
returned from the <SMALL>INSERT</SMALL> statement to look up the
|
||||||
default value, though this is probably the least portable approach,
|
default value, though this is probably the least portable approach,
|
||||||
and the oid value will wrap around when it reaches 4 billion.
|
and the oid value will wrap around when it reaches 4 billion.
|
||||||
@ -1082,13 +1074,13 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
available via <I>$sth->{pg_oid_status}</I> after
|
available via <I>$sth->{pg_oid_status}</I> after
|
||||||
<I>$sth->execute()</I>.</P>
|
<I>$sth->execute()</I>.</P>
|
||||||
|
|
||||||
<H4><A name="4.14.3">4.14.3</A>) Doesn't <I>currval()</I>
|
<H4><A name="4.13.3">4.13.3</A>) Doesn't <I>currval()</I>
|
||||||
lead to a race condition with other users?</H4>
|
lead to a race condition with other users?</H4>
|
||||||
|
|
||||||
<P>No. <I>currval()</I> returns the current value assigned by your
|
<P>No. <I>currval()</I> returns the current value assigned by your
|
||||||
backend, not by all users.</P>
|
backend, not by all users.</P>
|
||||||
|
|
||||||
<H4><A name="4.14.4">4.14.4</A>) Why aren't my sequence numbers
|
<H4><A name="4.13.4">4.13.4</A>) Why aren't my sequence numbers
|
||||||
reused on transaction abort? Why are there gaps in the numbering of
|
reused on transaction abort? Why are there gaps in the numbering of
|
||||||
my sequence/SERIAL column?</H4>
|
my sequence/SERIAL column?</H4>
|
||||||
|
|
||||||
@ -1097,7 +1089,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
completes. This causes gaps in numbering from aborted
|
completes. This causes gaps in numbering from aborted
|
||||||
transactions.</P>
|
transactions.</P>
|
||||||
|
|
||||||
<H4><A name="4.15">4.15</A>) What is an <SMALL>OID</SMALL>? What is
|
<H4><A name="4.14">4.14</A>) What is an <SMALL>OID</SMALL>? What is
|
||||||
a <SMALL>TID</SMALL>?</H4>
|
a <SMALL>TID</SMALL>?</H4>
|
||||||
|
|
||||||
<P>Every row that is created in PostgreSQL gets a unique
|
<P>Every row that is created in PostgreSQL gets a unique
|
||||||
@ -1120,7 +1112,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
are modified or reloaded. They are used by index entries to point
|
are modified or reloaded. They are used by index entries to point
|
||||||
to physical rows.</P>
|
to physical rows.</P>
|
||||||
|
|
||||||
<H4><A name="4.16">4.16</A>) What is the meaning of some of the
|
<H4><A name="4.15">4.15</A>) What is the meaning of some of the
|
||||||
terms used in PostgreSQL?</H4>
|
terms used in PostgreSQL?</H4>
|
||||||
|
|
||||||
<P>Some of the source code and older documentation use terms that
|
<P>Some of the source code and older documentation use terms that
|
||||||
@ -1149,7 +1141,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
<P>A list of general database terms can be found at: <A href=
|
<P>A list of general database terms can be found at: <A href=
|
||||||
"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.html</A></P>
|
"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.html</A></P>
|
||||||
|
|
||||||
<H4><A name="4.17">4.17</A>) Why do I get the error <I>"ERROR:
|
<H4><A name="4.16">4.16</A>) Why do I get the error <I>"ERROR:
|
||||||
Memory exhausted in AllocSetAlloc()"</I>?</H4>
|
Memory exhausted in AllocSetAlloc()"</I>?</H4>
|
||||||
|
|
||||||
<P>You probably have run out of virtual memory on your system,
|
<P>You probably have run out of virtual memory on your system,
|
||||||
@ -1168,12 +1160,12 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
backend is returning too much data, try it before starting the
|
backend is returning too much data, try it before starting the
|
||||||
client.
|
client.
|
||||||
|
|
||||||
<H4><A name="4.18">4.18</A>) How do I tell what PostgreSQL version
|
<H4><A name="4.17">4.17</A>) How do I tell what PostgreSQL version
|
||||||
I am running?</H4>
|
I am running?</H4>
|
||||||
|
|
||||||
<P>From <I>psql</I>, type <CODE>SELECT version();</CODE></P>
|
<P>From <I>psql</I>, type <CODE>SELECT version();</CODE></P>
|
||||||
|
|
||||||
<H4><A name="4.19">4.19</A>) Why does my large-object operations
|
<H4><A name="4.18">4.18</A>) Why does my large-object operations
|
||||||
get <I>"invalid large obj descriptor"</I>?</H4>
|
get <I>"invalid large obj descriptor"</I>?</H4>
|
||||||
|
|
||||||
<P>You need to put <CODE>BEGIN WORK</CODE> and <CODE>COMMIT</CODE>
|
<P>You need to put <CODE>BEGIN WORK</CODE> and <CODE>COMMIT</CODE>
|
||||||
@ -1189,7 +1181,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
<P>If you are using a client interface like <SMALL>ODBC</SMALL> you
|
<P>If you are using a client interface like <SMALL>ODBC</SMALL> you
|
||||||
may need to set <CODE>auto-commit off.</CODE></P>
|
may need to set <CODE>auto-commit off.</CODE></P>
|
||||||
|
|
||||||
<H4><A name="4.20">4.20</A>) How do I create a column that will
|
<H4><A name="4.19">4.19</A>) How do I create a column that will
|
||||||
default to the current time?</H4>
|
default to the current time?</H4>
|
||||||
|
|
||||||
<P>Use <I>CURRENT_TIMESTAMP</I>:</P>
|
<P>Use <I>CURRENT_TIMESTAMP</I>:</P>
|
||||||
@ -1198,7 +1190,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
</CODE>
|
</CODE>
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
<H4><A name="4.21">4.21</A>) Why are my subqueries using
|
<H4><A name="4.20">4.20</A>) Why are my subqueries using
|
||||||
<CODE><SMALL>IN</SMALL></CODE> so slow?</H4>
|
<CODE><SMALL>IN</SMALL></CODE> so slow?</H4>
|
||||||
|
|
||||||
<P>In versions prior to 7.4, subqueries were joined to outer queries
|
<P>In versions prior to 7.4, subqueries were joined to outer queries
|
||||||
@ -1222,7 +1214,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
sophisticated join techniques as normal queries, and is prefered
|
sophisticated join techniques as normal queries, and is prefered
|
||||||
to using <CODE>EXISTS</CODE>.
|
to using <CODE>EXISTS</CODE>.
|
||||||
|
|
||||||
<H4><A name="4.22">4.22</A>) How do I perform an outer join?</H4>
|
<H4><A name="4.21">4.21</A>) How do I perform an outer join?</H4>
|
||||||
|
|
||||||
<P>PostgreSQL supports outer joins using the SQL standard syntax.
|
<P>PostgreSQL supports outer joins using the SQL standard syntax.
|
||||||
Here are two examples:</P>
|
Here are two examples:</P>
|
||||||
@ -1262,7 +1254,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
ORDER BY col1
|
ORDER BY col1
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
<H4><A name="4.23">4.23</A>) How do I perform queries using
|
<H4><A name="4.22">4.22</A>) How do I perform queries using
|
||||||
multiple databases?</H4>
|
multiple databases?</H4>
|
||||||
|
|
||||||
<P>There is no way to query a database other than the current one.
|
<P>There is no way to query a database other than the current one.
|
||||||
@ -1274,7 +1266,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
connections to different databases and merge the results on the
|
connections to different databases and merge the results on the
|
||||||
client side.</P>
|
client side.</P>
|
||||||
|
|
||||||
<H4><A name="4.24">4.24</A>) How do I return multiple rows or
|
<H4><A name="4.23">4.23</A>) How do I return multiple rows or
|
||||||
columns from a function?</H4>
|
columns from a function?</H4>
|
||||||
|
|
||||||
<P>In 7.3, you can easily return multiple rows or columns from a
|
<P>In 7.3, you can easily return multiple rows or columns from a
|
||||||
@ -1282,7 +1274,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
<a href="http://techdocs.postgresql.org/guides/SetReturningFunctions">
|
<a href="http://techdocs.postgresql.org/guides/SetReturningFunctions">
|
||||||
http://techdocs.postgresql.org/guides/SetReturningFunctions</a>.
|
http://techdocs.postgresql.org/guides/SetReturningFunctions</a>.
|
||||||
|
|
||||||
<H4><A name="4.25">4.25</A>) Why can't I reliably create/drop
|
<H4><A name="4.24">4.24</A>) Why can't I reliably create/drop
|
||||||
temporary tables in PL/PgSQL functions?</H4>
|
temporary tables in PL/PgSQL functions?</H4>
|
||||||
<P>PL/PgSQL caches function contents, and an unfortunate side effect
|
<P>PL/PgSQL caches function contents, and an unfortunate side effect
|
||||||
is that if a PL/PgSQL function accesses a temporary table, and that
|
is that if a PL/PgSQL function accesses a temporary table, and that
|
||||||
@ -1292,7 +1284,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
|
|||||||
<SMALL>EXECUTE</SMALL> for temporary table access in PL/PgSQL. This
|
<SMALL>EXECUTE</SMALL> for temporary table access in PL/PgSQL. This
|
||||||
will cause the query to be reparsed every time.</P>
|
will cause the query to be reparsed every time.</P>
|
||||||
|
|
||||||
<H4><A name="4.26">4.26</A>) What encryption options are available?
|
<H4><A name="4.25">4.25</A>) What encryption options are available?
|
||||||
</H4>
|
</H4>
|
||||||
<UL>
|
<UL>
|
||||||
<LI><I>contrib/pgcrypto</I> contains many encryption functions for
|
<LI><I>contrib/pgcrypto</I> contains many encryption functions for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user