Commit 1b342df0 authored by Peter Eisentraut's avatar Peter Eisentraut

Merge documentation updates from 7.3 branch.

parent b3279066
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.30 2002/10/24 17:48:54 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.31 2002/11/11 20:14:02 petere Exp $
-->
<chapter id="tutorial-advanced">
......@@ -46,14 +46,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.30 2002/10/24 17:48:54 pe
<firstterm>view</firstterm> over the query, which gives a name to
the query that you can refer to like an ordinary table.
<programlisting>
<programlisting>
CREATE VIEW myview AS
SELECT city, temp_lo, temp_hi, prcp, date, location
FROM weather, cities
WHERE city = name;
SELECT * FROM myview;
</programlisting>
</programlisting>
</para>
<para>
......@@ -101,7 +101,7 @@ SELECT * FROM myview;
<para>
The new declaration of the tables would look like this:
<programlisting>
<programlisting>
CREATE TABLE cities (
city varchar(80) primary key,
location point
......@@ -114,23 +114,23 @@ CREATE TABLE weather (
prcp real,
date date
);
</programlisting>
</programlisting>
Now try inserting an invalid record:
<programlisting>
<programlisting>
INSERT INTO weather VALUES ('Berkeley', 45, 53, 0.0, '1994-11-28');
</programlisting>
</programlisting>
<screen>
<screen>
ERROR: &lt;unnamed&gt; referential integrity violation - key referenced from weather not found in cities
</screen>
</screen>
</para>
<para>
The behavior of foreign keys can be finely tuned to your
application. We will not go beyond this simple example in this
tutorial, but just refer you to the &cite-reference;
tutorial, but just refer you to the &cite-user;
for more information. Making correct use of
foreign keys will definitely improve the quality of your database
applications, so you are strongly encouraged to learn about them.
......@@ -161,7 +161,7 @@ ERROR: &lt;unnamed&gt; referential integrity violation - key referenced from we
to Bob's account. Simplifying outrageously, the SQL commands for this
might look like
<programlisting>
<programlisting>
UPDATE accounts SET balance = balance - 100.00
WHERE name = 'Alice';
UPDATE branches SET balance = balance - 100.00
......@@ -170,7 +170,7 @@ UPDATE accounts SET balance = balance + 100.00
WHERE name = 'Bob';
UPDATE branches SET balance = balance + 100.00
WHERE name = (SELECT branch_name FROM accounts WHERE name = 'Bob');
</programlisting>
</programlisting>
</para>
<para>
......@@ -222,13 +222,13 @@ UPDATE branches SET balance = balance + 100.00
<command>BEGIN</> and <command>COMMIT</> commands. So our banking
transaction would actually look like
<programlisting>
<programlisting>
BEGIN;
UPDATE accounts SET balance = balance - 100.00
WHERE name = 'Alice';
-- etc etc
COMMIT;
</programlisting>
</programlisting>
</para>
<para>
......@@ -278,7 +278,7 @@ COMMIT;
implicitly when you list all cities. If you're really clever you
might invent some scheme like this:
<programlisting>
<programlisting>
CREATE TABLE capitals (
name text,
population real,
......@@ -296,7 +296,7 @@ CREATE VIEW cities AS
SELECT name, population, altitude FROM capitals
UNION
SELECT name, population, altitude FROM non_capitals;
</programlisting>
</programlisting>
This works OK as far as querying goes, but it gets ugly when you
need to update several rows, to name one thing.
......@@ -305,7 +305,7 @@ CREATE VIEW cities AS
<para>
A better solution is this:
<programlisting>
<programlisting>
CREATE TABLE cities (
name text,
population real,
......@@ -315,7 +315,7 @@ CREATE TABLE cities (
CREATE TABLE capitals (
state char(2)
) INHERITS (cities);
</programlisting>
</programlisting>
</para>
<para>
......@@ -336,11 +336,11 @@ CREATE TABLE capitals (
including state capitals, that are located at an altitude
over 500 ft.:
<programlisting>
<programlisting>
SELECT name, altitude
FROM cities
WHERE altitude &gt; 500;
</programlisting>
</programlisting>
which returns:
......@@ -359,11 +359,11 @@ SELECT name, altitude
all the cities that are not state capitals and
are situated at an altitude of 500 ft. or higher:
<programlisting>
<programlisting>
SELECT name, altitude
FROM ONLY cities
WHERE altitude &gt; 500;
</programlisting>
</programlisting>
<screen>
name | altitude
......@@ -380,7 +380,7 @@ SELECT name, altitude
<classname>cities</classname> table, and not tables below
<classname>cities</classname> in the inheritance hierarchy. Many
of the commands that we have already discussed --
<command>SELECT</command>, <command>UPDATE</command> and
<command>SELECT</command>, <command>UPDATE</command>, and
<command>DELETE</command> -- support this <literal>ONLY</literal>
notation.
</para>
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.23 2002/11/10 00:32:16 momjian Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.24 2002/11/11 20:14:02 petere Exp $ -->
<sect1 id="arrays">
<title>Arrays</title>
......@@ -21,7 +21,7 @@ CREATE TABLE sal_emp (
</programlisting>
As shown, an array data type is named by appending square brackets
(<literal>[]</>) to the data type name of the array elements.
The above query will create a table named
The above command will create a table named
<structname>sal_emp</structname> with columns including
a <type>text</type> string (<structfield>name</structfield>),
a one-dimensional array of type
......@@ -68,7 +68,7 @@ SELECT name FROM sal_emp WHERE pay_by_quarter[1] &lt;&gt; pay_by_quarter[2];
The array subscript numbers are written within square brackets.
By default <productname>PostgreSQL</productname> uses the
<quote>one-based</quote> numbering convention for arrays, that is,
one-based numbering convention for arrays, that is,
an array of <replaceable>n</> elements starts with <literal>array[1]</literal> and
ends with <literal>array[<replaceable>n</>]</literal>.
</para>
......@@ -90,10 +90,9 @@ SELECT pay_by_quarter[3] FROM sal_emp;
<para>
We can also access arbitrary rectangular slices of an array, or
subarrays. An array slice is denoted by writing
<literal><replaceable>lower subscript</replaceable> :
<replaceable>upper subscript</replaceable></literal> for one or more
array dimensions. This query retrieves the first item on Bill's
schedule for the first two days of the week:
<literal><replaceable>lower-bound</replaceable>:<replaceable>upper-bound</replaceable></literal>
for one or more array dimensions. This query retrieves the first
item on Bill's schedule for the first two days of the week:
<programlisting>
SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill';
......@@ -112,9 +111,10 @@ SELECT schedule[1:2][1] FROM sal_emp WHERE name = 'Bill';
with the same result. An array subscripting operation is taken to
represent an array slice if any of the subscripts are written in the
form <replaceable>lower</replaceable> <literal>:</literal>
<replaceable>upper</replaceable>. A lower bound of 1 is assumed for
any subscript where only one value is specified.
form
<literal><replaceable>lower</replaceable>:<replaceable>upper</replaceable></literal>.
A lower bound of 1 is assumed for any subscript where only one value
is specified.
</para>
<para>
......@@ -310,7 +310,7 @@ SELECT * FROM sal_emp WHERE pay_by_quarter **= 10000;
<tip>
<para>
Remember that what you write in an SQL query will first be interpreted
Remember that what you write in an SQL command will first be interpreted
as a string literal, and then as an array. This doubles the number of
backslashes you need. For example, to insert a <type>text</> array
value containing a backslash and a double quote, you'd need to write
......@@ -323,7 +323,7 @@ INSERT ... VALUES ('{"\\\\","\\""}');
become <literal>\</> and <literal>"</> respectively. (If we were working
with a data type whose input routine also treated backslashes specially,
<type>bytea</> for example, we might need as many as eight backslashes
in the query to get one backslash into the stored array element.)
in the command to get one backslash into the stored array element.)
</para>
</tip>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/backup.sgml,v 2.23 2002/10/21 02:11:37 tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/backup.sgml,v 2.24 2002/11/11 20:14:02 petere Exp $
-->
<chapter id="backup">
<title>Backup and Restore</title>
......@@ -64,7 +64,7 @@ pg_dump <replaceable class="parameter">dbname</replaceable> &gt; <replaceable cl
<para>
As any other <productname>PostgreSQL</> client application,
<application>pg_dump</> will by default connect with the database
user name that is equal to the current Unix user name. To override
user name that is equal to the current operating system user name. To override
this, either specify the <option>-U</option> option or set the
environment variable <envar>PGUSER</envar>. Remember that
<application>pg_dump</> connections are subject to the normal
......@@ -104,9 +104,9 @@ psql <replaceable class="parameter">dbname</replaceable> &lt; <replaceable class
</synopsis>
where <replaceable class="parameter">infile</replaceable> is what
you used as <replaceable class="parameter">outfile</replaceable>
for the pg_dump command. The database <replaceable
for the <command>pg_dump</> command. The database <replaceable
class="parameter">dbname</replaceable> will not be created by this
command, you must create it yourself from template0 before executing
command, you must create it yourself from <literal>template0</> before executing
<application>psql</> (e.g., with <literal>createdb -T template0
<replaceable class="parameter">dbname</></literal>).
<application>psql</> supports similar options to <application>pg_dump</>
......@@ -129,23 +129,22 @@ psql <replaceable class="parameter">dbname</replaceable> &lt; <replaceable class
The ability of <application>pg_dump</> and <application>psql</> to
write to or read from pipes makes it possible to dump a database
directly from one server to another, for example
<informalexample>
<programlisting>
pg_dump -h <replaceable>host1</> <replaceable>dbname</> | psql -h <replaceable>host2</> <replaceable>dbname</>
</programlisting>
</informalexample>
</para>
<important>
<para>
The dumps produced by pg_dump are relative to template0. This means
that any languages, procedures, etc. added to template1 will also be
dumped by <application>pg_dump</>. As a result, when restoring, if
you are using a customized template1, you must create the empty
database from template0, as in the example above.
</para>
</important>
<important>
<para>
The dumps produced by <application>pg_dump</> are relative to
<literal>template0</>. This means that any languages, procedures,
etc. added to <literal>template1</> will also be dumped by
<application>pg_dump</>. As a result, when restoring, if you are
using a customized <literal>template1</>, you must create the
empty database from <literal>template0</>, as in the example
above.
</para>
</important>
</sect2>
......@@ -222,20 +221,16 @@ cat <replaceable class="parameter">filename</replaceable>.gz | gunzip | psql <re
acceptable in size to the underlying file system. For example, to
make chunks of 1 megabyte:
<informalexample>
<programlisting>
pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 1m - <replaceable class="parameter">filename</replaceable>
</programlisting>
</informalexample>
Reload with
<informalexample>
<programlisting>
createdb <replaceable class="parameter">dbname</replaceable>
cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable class="parameter">dbname</replaceable>
</programlisting>
</informalexample>
</para>
</formalpara>
......@@ -249,14 +244,11 @@ cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable c
restored selectively. The following command dumps a database using the
custom dump format:
<informalexample>
<programlisting>
pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable class="parameter">filename</replaceable>
</programlisting>
</informalexample>
See the <application>pg_dump</> and <application>pg_restore</> reference pages for details.
</para>
</formalpara>
......@@ -284,7 +276,7 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable c
<para>
For reasons of backward compatibility, <application>pg_dump</> does
not dump large objects by default. To dump large objects you must use
either the custom or the TAR output format, and use the -b option in
either the custom or the TAR output format, and use the <option>-b</> option in
<application>pg_dump</>. See the reference pages for details.
The directory <filename>contrib/pg_dumplo</> of the
<productname>PostgreSQL</> source tree also contains a program that can
......@@ -308,11 +300,10 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable c
are located, but you have probably found them already if you are
interested in this method. You can use whatever method you prefer
for doing usual file system backups, for example
<informalexample>
<programlisting>
tar -cf backup.tar /usr/local/pgsql/data
</programlisting>
</informalexample>
</para>
<para>
......@@ -390,11 +381,11 @@ tar -cf backup.tar /usr/local/pgsql/data
The least downtime can be achieved by installing the new server in
a different directory and running both the old and the new servers
in parallel, on different ports. Then you can use something like
<informalexample>
<programlisting>
pg_dumpall -p 5432 | psql -d template1 -p 6543
</programlisting>
</informalexample>
to transfer your data, or use an intermediate file if you want.
Then you can shut down the old server and start the new server at
the port the old one was running at. You should make sure that the
......@@ -410,7 +401,7 @@ pg_dumpall -p 5432 | psql -d template1 -p 6543
do the back up step before installing the new version, bring down
the server, move the old version out of the way, install the new
version, start the new server, restore the data. For example:
<informalexample>
<programlisting>
pg_dumpall > backup
pg_ctl stop
......@@ -421,7 +412,7 @@ initdb -D /usr/local/pgsql/data
postmaster -D /usr/local/pgsql/data
psql template1 < backup
</programlisting>
</informalexample>
See <xref linkend="runtime"> about ways to start and stop the
server and other details. The installation instructions will advise
you of strategic places to perform these steps.
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/client-auth.sgml,v 1.39 2002/09/21 18:32:52 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/client-auth.sgml,v 1.40 2002/11/11 20:14:02 petere Exp $
-->
<chapter id="client-authentication">
......@@ -62,7 +62,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/client-auth.sgml,v 1.39 2002/09/21 18:32:52
</para>
<para>
The general format of the <filename>pg_hba.conf</filename> file is of
The general format of the <filename>pg_hba.conf</filename> file is
a set of records, one per line. Blank lines are ignored, as is any
text after the <quote>#</quote> comment character. A record is made
up of a number of fields which are separated by spaces and/or tabs.
......@@ -305,8 +305,9 @@ hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <
<para>
If you use the map <literal>sameuser</literal>, the user
names are assumed to be identical. If not, the map name is
looked up in the <literal>$PGDATA/pg_ident.conf</literal>
file. The connection is accepted if that file contains an
looked up in the file <filename>pg_ident.conf</filename>
in the same directory as <filename>pg_hba.conf</filename>.
The connection is accepted if that file contains an
entry for this map name with the ident-supplied user name
and the requested <productname>PostgreSQL</productname> user
name.
......@@ -473,7 +474,7 @@ local db1,db2,@demodbs all md5
<para>
When <literal>trust</> authentication is specified,
<productname>PostgreSQL</productname> assumes that anyone who can
connect to the postmaster is authorized to access the database as
connect to the server is authorized to access the database as
whatever database user he specifies (including the database superuser).
This method should only be used when there is adequate system-level
protection on connections to the postmaster port.
......@@ -504,7 +505,7 @@ local db1,db2,@demodbs all md5
<para>
<literal>trust</> authentication is only suitable for TCP connections
if you trust every user on every machine that is allowed to connect
to the postmaster by the <filename>pg_hba.conf</> lines that specify
to the server by the <filename>pg_hba.conf</> lines that specify
<literal>trust</>. It is seldom reasonable to use <literal>trust</>
for any TCP connections other than those from <systemitem>localhost</> (127.0.0.1).
</para>
......@@ -538,14 +539,14 @@ local db1,db2,@demodbs all md5
<para>
<productname>PostgreSQL</productname> database passwords are
separate from operating system user passwords. Ordinarily, the
password for each database user is stored in the pg_shadow system
separate from operating system user passwords. The password for
each database user is stored in the <literal>pg_shadow</> system
catalog table. Passwords can be managed with the query language
commands <command>CREATE USER</command> and <command>ALTER
USER</command>, e.g., <userinput>CREATE USER foo WITH PASSWORD
'secret';</userinput>. By default, that is, if no password has been
set up, the stored password is <literal>NULL</literal> and password
authentication will always fail for that user.
'secret';</userinput>. By default, that is, if no password has
been set up, the stored password is null and
password authentication will always fail for that user.
</para>
<para>
......@@ -554,8 +555,8 @@ local db1,db2,@demodbs all md5
file. The file should contain user names separated by commas or one
user name per line, and be in the same directory as
<filename>pg_hba.conf</>. Mention the (base) name of the file
preceded with <literal>@</>in the <literal>USER</> column. The
<literal>DATABASE</> column can similarly accept a list of values or
preceded with <literal>@</> in the user column. The
database column can similarly accept a list of values or
a file name. You can also specify group names by preceding the group
name with <literal>+</>.
</para>
......@@ -715,7 +716,7 @@ local db1,db2,@demodbs all md5
Unix-domain sockets (currently <systemitem
class="osname">Linux</>, <systemitem class="osname">FreeBSD</>,
<systemitem class="osname">NetBSD</>, and <systemitem
class="osname">BSD/OS</>, ident authentication can also be applied
class="osname">BSD/OS</>), ident authentication can also be applied
to local connections. In this case, no security risk is added by
using ident authentication; indeed it is a preferable choice for
local connections on such systems.
......
This diff is collapsed.
This diff is collapsed.
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ddl.sgml,v 1.8 2002/10/24 21:10:58 tgl Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ddl.sgml,v 1.9 2002/11/11 20:14:02 petere Exp $ -->
<chapter id="ddl">
<title>Data Definition</title>
......@@ -222,7 +222,7 @@ DROP TABLE products;
<para>
The identity (transaction ID) of the deleting transaction, or
zero for an undeleted tuple. It is possible for this field to
be nonzero in a visible tuple: that usually indicates that the
be nonzero in a visible tuple: That usually indicates that the
deleting transaction hasn't committed yet, or that an attempted
deletion was rolled back.
</para>
......@@ -353,7 +353,7 @@ CREATE TABLE products (
price numeric <emphasis>CONSTRAINT positive_price</emphasis> CHECK (price > 0)
);
</programlisting>
To specify a named constraint, use the key word
So, to specify a named constraint, use the key word
<literal>CONSTRAINT</literal> followed by an identifier followed
by the constraint definition.
</para>
......@@ -382,7 +382,7 @@ CREATE TABLE products (
</para>
<para>
We say that the first two are column constraints, whereas the
We say that the first two constraints are column constraints, whereas the
third one is a table constraint because it is written separately
from the column definitions. Column constraints can also be
written as table constraints, while the reverse is not necessarily
......@@ -931,7 +931,7 @@ WHERE c.altitude &gt; 500 and c.tableoid = p.oid;
<para>
In previous versions of <productname>PostgreSQL</productname>, the
default was not to get access to child tables. This was found to
be error prone and is also in violation of SQL99. Under the old
be error prone and is also in violation of the SQL standard. Under the old
syntax, to get the sub-tables you append <literal>*</literal> to the table name.
For example
<programlisting>
......@@ -1609,7 +1609,7 @@ REVOKE CREATE ON public FROM PUBLIC;
standard. Therefore, many users consider qualified names to
really consist of
<literal><replaceable>username</>.<replaceable>tablename</></literal>.
This is also supported by PostgreSQL if you create a per-user
This is how PostgreSQL will effectively behave if you create a per-user
schema for every user.
</para>
......@@ -1693,8 +1693,8 @@ DROP TABLE products CASCADE;
</screen>
and all the dependent objects will be removed. In this case, it
doesn't remove the orders table, it only removes the foreign key
constraint. (If you want to check what DROP ... CASCADE will do,
run DROP without CASCADE and read the NOTICEs.)
constraint. (If you want to check what <literal>DROP ... CASCADE</> will do,
run <command>DROP</> without <literal>CASCADE</> and read the <literal>NOTICE</> messages.)
</para>
<para>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/diskusage.sgml,v 1.6 2002/10/16 22:06:33 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/diskusage.sgml,v 1.7 2002/11/11 20:14:02 petere Exp $
-->
<chapter id="diskusage">
......@@ -32,7 +32,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/diskusage.sgml,v 1.6 2002/10/16 22:06:33 pe
<para>
You can monitor disk space from three places: from
<application>psql</> using <command>VACUUM</> information, from
<application>psql</> using <application>contrib/dbsize</>, and from
<application>psql</> using <filename>contrib/dbsize</>, and from
the command line using <application>contrib/oid2name</>. Using
<application>psql</> on a recently vacuumed (or analyzed) database,
you can issue queries to see the disk usage of any table:
......@@ -94,13 +94,14 @@ play-# ORDER BY relpages DESC;
</para>
<para>
<application>dbsize</> loads functions into your database that allow
<filename>contrib/dbsize</> loads functions into your database that allow
you to find the size of a table or database from inside
<application>psql</> without the need for <command>VACUUM/ANALYZE.</>
</para>
<para>
You can also use <application>oid2name</> to show disk usage. See
<filename>README.oid2name</> for examples. It includes a script
You can also use <filename>contrib/oid2name</> to show disk usage. See
<filename>README.oid2name</> for examples. It includes a script that
shows disk usage for each database.
</para>
</sect1>
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/dml.sgml,v 1.2 2002/10/20 05:05:46 tgl Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/dml.sgml,v 1.3 2002/11/11 20:14:02 petere Exp $ -->
<chapter id="dml">
<title>Data Manipulation</title>
......@@ -23,10 +23,10 @@
<para>
When a table is created, it contains no data. The first thing to
do before a database can be of much use is to insert data. Data is
inserted one row at a time. This does not mean that there are no
means to <quote>bulk load</quote> many rows efficiently. But there
is no way to insert less than one row at a time. Even if you know
only some column values, a complete row must be created.
conceptually inserted one row at a time. Of course you can also
insert more than one row, but there is no way to insert less than
one row at a time. Even if you know only some column values, a
complete row must be created.
</para>
<para>
......@@ -84,6 +84,15 @@ INSERT INTO products (product_no, name, price) VALUES (1, 'Cheese', DEFAULT);
INSERT INTO products DEFAULT VALUES;
</programlisting>
</para>
<tip>
<para>
To do <quote>bulk loads</quote>, that is, inserting a lot of data,
take a look at the <command>COPY</command> command (see
&cite-reference;). It is not as flexible as the
<command>INSERT</command> command, but more efficient.
</para>
</tip>
</sect1>
<sect1 id="dml-update">
......
This diff is collapsed.
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/indices.sgml,v 1.37 2002/09/21 18:32:53 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/indices.sgml,v 1.38 2002/11/11 20:14:03 petere Exp $ -->
<chapter id="indexes">
<title id="indexes-title">Indexes</title>
......@@ -432,172 +432,6 @@ SELECT am.amname AS acc_method,
</sect1>
<sect1 id="keys">
<title id="keys-title">Keys</title>
<para>
<note>
<title>Author</title>
<para>
Written by Herouth Maoz (<email>herouth@oumail.openu.ac.il</email>).
This originally appeared on the User's Mailing List on 1998-03-02
in response to the question:
"What is the difference between PRIMARY KEY and UNIQUE constraints?".
</para>
</note>
</para>
<para>
<literallayout>
Subject: Re: [QUESTIONS] PRIMARY KEY | UNIQUE
What's the difference between:
PRIMARY KEY(fields,...) and
UNIQUE (fields,...)
- Is this an alias?
- If PRIMARY KEY is already unique, then why
is there another kind of key named UNIQUE?
</literallayout>
</para>
<para>
A primary key is the field(s) used to identify a specific row. For example,
Social Security numbers identifying a person.
</para>
<para>
A simply UNIQUE combination of fields has nothing to do with identifying
the row. It's simply an integrity constraint. For example, I have
collections of links. Each collection is identified by a unique number,
which is the primary key. This key is used in relations.
</para>
<para>
However, my application requires that each collection will also have a
unique name. Why? So that a human being who wants to modify a collection
will be able to identify it. It's much harder to know, if you have two
collections named <quote>Life Science</quote>, the one tagged 24433 is the one you
need, and the one tagged 29882 is not.
</para>
<para>
So, the user selects the collection by its name. We therefore make sure,
within the database, that names are unique. However, no other table in the
database relates to the collections table by the collection Name. That
would be very inefficient.
</para>
<para>
Moreover, despite being unique, the collection name does not actually
define the collection! For example, if somebody decided to change the name
of the collection from <quote>Life Science</quote> to <quote>Biology</quote>, it will still be the
same collection, only with a different name. As long as the name is unique,
that's OK.
</para>
<para>
So:
<itemizedlist>
<listitem>
<para>
Primary key:
<itemizedlist spacing="compact" mark="bullet">
<listitem>
<para>
Is used for identifying the row and relating to it.
</para>
</listitem>
<listitem>
<para>
Is impossible (or hard) to update.
</para>
</listitem>
<listitem>
<para>
Should not allow null values.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
Unique field(s):
<itemizedlist spacing="compact" mark="bullet">
<listitem>
<para>
Are used as an alternative access to the row.
</para>
</listitem>
<listitem>
<para>
Are updatable, so long as they are kept unique.
</para>
</listitem>
<listitem>
<para>
Null values are acceptable.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</itemizedlist>
</para>
<para>
As for why no non-unique keys are defined explicitly in standard
<acronym>SQL</acronym> syntax? Well, you
must understand that indexes are implementation-dependent.
<acronym>SQL</acronym> does not
define the implementation, merely the relations between data in the
database. <productname>PostgreSQL</productname> does allow
non-unique indexes, but indexes
used to enforce <acronym>SQL</acronym> keys are always unique.
</para>
<para>
Thus, you may query a table by any combination of its columns, despite the
fact that you don't have an index on these columns. The indexes are merely
an implementation aid that each <acronym>RDBMS</acronym> offers
you, in order to cause
commonly used queries to be done more efficiently.
Some <acronym>RDBMS</acronym> may give you
additional measures, such as keeping a key stored in main memory. They will
have a special command, for example
<synopsis>
CREATE MEMSTORE ON <replaceable>table</replaceable> COLUMNS <replaceable>cols</replaceable>
</synopsis>
(This is not an existing command, just an example.)
</para>
<para>
In fact, when you create a primary key or a unique combination of fields,
nowhere in the <acronym>SQL</acronym> specification does it say
that an index is created, nor that
the retrieval of data by the key is going to be more efficient than a
sequential scan!
</para>
<para>
So, if you want to use a combination of fields that is not unique as a
secondary key, you really don't have to specify anything - just start
retrieving by that combination! However, if you want to make the retrieval
efficient, you'll have to resort to the means your
<acronym>RDBMS</acronym> provider gives you
- be it an index, my imaginary <literal>MEMSTORE</literal> command, or an intelligent
<acronym>RDBMS</acronym>
that creates indexes without your knowledge based on the fact that you have
sent it many queries based on a specific combination of keys... (It learns
from experience).
</para>
</sect1>
<sect1 id="indexes-partial">
<title>Partial Indexes</title>
......@@ -876,8 +710,8 @@ CREATE UNIQUE INDEX tests_success_constraint ON tests (subject, target)
<para>
When indexes are not used, it can be useful for testing to force
their use. There are run-time parameters that can turn off
various plan types (described in the <citetitle>Administrator's
Guide</citetitle>). For instance, turning off sequential scans
various plan types (described in the &cite-admin;).
For instance, turning off sequential scans
(<varname>enable_seqscan</>) and nested-loop joins
(<varname>enable_nestloop</>), which are the most basic plans,
will force the system to use a different plan. If the system
......@@ -906,8 +740,8 @@ CREATE UNIQUE INDEX tests_success_constraint ON tests (subject, target)
again, two possibilities. The total cost is computed from the
per-row costs of each plan node times the selectivity estimate of
the plan node. The costs of the plan nodes can be tuned with
run-time parameters (described in the <citetitle>Administrator's
Guide</citetitle>). An inaccurate selectivity estimate is due to
run-time parameters (described in the &cite-admin;).
An inaccurate selectivity estimate is due to
insufficient statistics. It may be possible to help this by
tuning the statistics-gathering parameters (see <command>ALTER
TABLE</command> reference).
......
......@@ -6,14 +6,6 @@
<secondary>on Windows</secondary>
</indexterm>
<abstract>
<para>
Build, installation, and use instructions for
<productname>PostgreSQL</productname> client libraries on
<productname>Windows</productname>
</para>
</abstract>
<para>
Although <productname>PostgreSQL</productname> is written for
Unix-like operating systems, the C client library
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.110 2002/11/05 19:01:07 momjian Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.111 2002/11/11 20:14:03 petere Exp $ -->
<chapter id="installation">
<title><![%standalone-include[<productname>PostgreSQL</>]]>
......@@ -8,6 +8,13 @@
<primary>installation</primary>
</indexterm>
<para>
This <![%standalone-include;[document.]]>
<![%standalone-ignore;[chapter.]]> describes the installation of
<productname>PostgreSQL</productname> from the source code
distribution.
</para>
<sect1 id="install-short">
<title>Short Version</title>
......@@ -131,27 +138,30 @@ su - postgres
<para>
To build the server programming language PL/Perl you need a full
Perl installation, including the <filename>libperl</filename>
library and the header files. Since PL/Perl is a shared
library and the header files. Since PL/Perl will be a shared
library, the <indexterm><primary>libperl</primary></indexterm>
<filename>libperl</filename> library must be a shared library
also on most platforms. At the time of this writing, this is
almost never the case in prebuilt Perl packages.
also on most platforms. This appears to be the default in
recent Perl versions, but it was not in earlier versions, and in
general it is the choice of whomever installed Perl at your
site.
</para>
<para>
If this difficulty arises in your situation, a message like this
will appear during the build to point out this fact:
If you don't have the shared library but you need one, a message
like this will appear during the build to point out this fact:
<screen>
*** Cannot build PL/Perl because libperl is not a shared library.
*** You might have to rebuild your Perl installation. Refer to
*** the documentation for details.
</screen>
(If you don't follow the on-screen output you will merely notice
the the PL/Perl library object will not be installed.) If you
see this, you will have to re-build and install
<productname>Perl</productname> manually to be able to build
PL/Perl. During the configuration process for
<productname>Perl</productname>, request a shared library.
that the PL/Perl library object, <filename>plperl.so</filename>
or similar, will not be installed.) If you see this, you will
have to rebuild and install <productname>Perl</productname>
manually to be able to build PL/Perl. During the configuration
process for <productname>Perl</productname>, request a shared
library.
</para>
</listitem>
......@@ -160,17 +170,18 @@ su - postgres
To build the Python interface module or the PL/Python server
programming language, you need a Python installation, including
the header files.
</para>
<para>
Since PL/Python is a shared library, the
Since PL/Python will be a shared library, the
<indexterm><primary>libpython</primary></indexterm>
<filename>libpython</filename> library must be a shared library
also on most platforms. This is not the case in a default
Python installation. If after building and installing you have
a file called <filename>plpython.so</filename> (possibly a
different extension), then everything went well. Otherwise you
should have seen a notice like this flying by:
Python installation.
</para>
<para>
If after building and installing you have a file called
<filename>plpython.so</filename> (possibly a different
extension), then everything went well. Otherwise you should
have seen a notice like this flying by:
<screen>
*** Cannot build PL/Python because libpython is not a shared library.
*** You might have to rebuild your Python installation. Refer to
......@@ -282,7 +293,7 @@ JAVACMD=$JAVA_HOME/bin/java
<primary>yacc</primary>
</indexterm>
<acronym>GNU</> <application>Flex</> and <application>Bison</>
<application>Flex</> and <application>Bison</>
are needed to build a CVS checkout or if you changed the actual
scanner and parser definition files. If you need them, be sure
to get <application>Flex</> 2.5.4 or later and
......@@ -373,7 +384,7 @@ JAVACMD=$JAVA_HOME/bin/java
<primary>pg_dumpall</primary>
</indexterm>
To dump your database installation, type:
To back up your database installation, type:
<screen>
<userinput>pg_dumpall &gt; <replaceable>outputfile</></userinput>
</screen>
......@@ -391,9 +402,16 @@ JAVACMD=$JAVA_HOME/bin/java
</para>
<para>
Make sure that you use the <command>pg_dumpall</> command
from the version you are currently running. &version;'s
<command>pg_dumpall</> should not be used on older databases.
To make the backup, you can use the <command>pg_dumpall</command>
command from the version you are currently running. For best
results, however, try to use the <command>pg_dumpall</command>
command from PostgreSQL &version;, since this version contains
bug fixes and improvements over older versions. While this
advice might seem idiosyncratic since you haven't installed the
new version yet, it is advisable to follow it if you plan to
install the new version in parallel with the old version. In
that case you can complete the installation normally and transfer
the data later. This will also decrease the downtime.
</para>
</step>
......@@ -453,12 +471,10 @@ JAVACMD=$JAVA_HOME/bin/java
</para>
<para>
You can also install the new version in parallel with the old one
to decrease the downtime. These topics are discussed at length in
<![%standalone-include[the <citetitle>Administrator's Guide</>,]]>
<![%standalone-ignore[<xref linkend="migration">,]]>
which you are encouraged
to read in any case.
These topics are discussed at length in <![%standalone-include[the
<citetitle>Administrator's Guide</>,]]> <![%standalone-ignore[<xref
linkend="migration">,]]> which you are encouraged to read in any
case.
</para>
</sect1>
......@@ -751,10 +767,6 @@ JAVACMD=$JAVA_HOME/bin/java
server-side language. You need to have root access to be able
to install the Python module at its default place
(<filename>/usr/lib/python<replaceable>x</>.<replaceable>y</></>).
To be able to use this option, you must have Python installed
and your system needs to support shared libraries. If you
instead want to build a new complete interpreter binary, you
will have to do it manually.
</para>
</listitem>
</varlistentry>
......@@ -763,7 +775,7 @@ JAVACMD=$JAVA_HOME/bin/java
<term><option>--with-tcl</option></term>
<listitem>
<para>
Builds components that require Tcl/Tk, which are
Build components that require Tcl/Tk, which are
<application>libpgtcl</>, <application>pgtclsh</>,
<application>pgtksh</application>,
and <application>PL/Tcl</>. But see below about
......@@ -1106,7 +1118,7 @@ All of PostgreSQL is successfully made. Ready to install.
</procedure>
<formalpara>
<title>Uninstall:</title>
<title>Uninstallation:</title>
<para>
To undo the installation use the command <command>gmake
uninstall</>. However, this will not remove any created directories.
......@@ -1192,7 +1204,7 @@ setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
<para>
On <systemitem class="osname">Cygwin</systemitem>, put the library
directory on the <envar>PATH</envar> or move the
directory in the <envar>PATH</envar> or move the
<filename>.dll</filename> files into the <filename>bin/</filename>
directory.
</para>
......@@ -1735,7 +1747,7 @@ gunzip -c user.ps.gz \
<entry>7.3</entry>
<entry>2002-11-01,
7.1.3 Larry Rosenman (<email>ler@lerctr.org</email>),
7.1.1 and 7.1.2(8.0.0) Olivier Prenant (<email>ohp@pyrenet.fr</email>)
7.1.1 and 7.1.2(8.0.0) Olivier Prenant (<email>ohp@pyrenet.fr</email>)</entry>
<entry>see also <filename>doc/FAQ_SCO</filename></entry>
</row>
<row>
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/keywords.sgml,v 2.7 2002/11/02 18:41:21 tgl Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/keywords.sgml,v 2.8 2002/11/11 20:14:03 petere Exp $ -->
<appendix id="sql-keywords-appendix">
<title><acronym>SQL</acronym> Key Words</title>
......@@ -232,13 +232,13 @@
</row>
<row>
<entry><token>ASSERTION</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>ASSIGNMENT</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
......@@ -262,7 +262,7 @@
</row>
<row>
<entry><token>AUTHORIZATION</token></entry>
<entry>non-reserved</entry>
<entry>reserved (can be function)</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -296,6 +296,12 @@
<entry>non-reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>BIGINT</token></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>BINARY</token></entry>
<entry>reserved (can be function)</entry>
......@@ -328,7 +334,7 @@
</row>
<row>
<entry><token>BOOLEAN</token></entry>
<entry></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>reserved</entry>
<entry></entry>
</row>
......@@ -370,7 +376,7 @@
</row>
<row>
<entry><token>CALLED</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
......@@ -490,7 +496,7 @@
</row>
<row>
<entry><token>CLASS</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry></entry>
</row>
......@@ -680,6 +686,12 @@
<entry>reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>CONVERSION</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>CONVERT</token></entry>
<entry>non-reserved (cannot be function or type)</entry>
......@@ -706,7 +718,7 @@
</row>
<row>
<entry><token>CREATE</token></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -832,7 +844,7 @@
</row>
<row>
<entry><token>DEALLOCATE</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -880,7 +892,7 @@
</row>
<row>
<entry><token>DEFINER</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
......@@ -988,7 +1000,7 @@
</row>
<row>
<entry><token>DOMAIN</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -1126,7 +1138,7 @@
</row>
<row>
<entry><token>EXTERNAL</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -1252,7 +1264,7 @@
</row>
<row>
<entry><token>GET</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -1276,7 +1288,7 @@
</row>
<row>
<entry><token>GRANT</token></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -1358,12 +1370,24 @@
<entry>reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>IMMUTABLE</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>IMPLEMENTATION</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
<row>
<entry><token>IMPLICIT</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>IN</token></entry>
<entry>reserved (can be function)</entry>
......@@ -1426,7 +1450,7 @@
</row>
<row>
<entry><token>INPUT</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -1462,13 +1486,13 @@
</row>
<row>
<entry><token>INT</token></entry>
<entry></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>INTEGER</token></entry>
<entry></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -1492,7 +1516,7 @@
</row>
<row>
<entry><token>INVOKER</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
......@@ -1642,13 +1666,13 @@
</row>
<row>
<entry><token>LOCALTIME</token></entry>
<entry></entry>
<entry>reserved</entry>
<entry>reserved</entry>
<entry></entry>
</row>
<row>
<entry><token>LOCALTIMESTAMP</token></entry>
<entry></entry>
<entry>reserved</entry>
<entry>reserved</entry>
<entry></entry>
</row>
......@@ -2056,7 +2080,7 @@
</row>
<row>
<entry><token>OVERLAY</token></entry>
<entry></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
......@@ -2156,6 +2180,12 @@
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>PLACING</token></entry>
<entry>reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>PLI</token></entry>
<entry></entry>
......@@ -2194,7 +2224,7 @@
</row>
<row>
<entry><token>PREPARE</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -2236,7 +2266,7 @@
</row>
<row>
<entry><token>PUBLIC</token></entry>
<entry>reserved (can be function)</entry>
<entry></entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -2254,10 +2284,16 @@
</row>
<row>
<entry><token>REAL</token></entry>
<entry></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>RECHECK</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>RECURSIVE</token></entry>
<entry></entry>
......@@ -2416,7 +2452,7 @@
</row>
<row>
<entry><token>ROW</token></entry>
<entry>non-reserved</entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>reserved</entry>
<entry></entry>
</row>
......@@ -2494,7 +2530,7 @@
</row>
<row>
<entry><token>SECURITY</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
......@@ -2578,13 +2614,13 @@
</row>
<row>
<entry><token>SIMILAR</token></entry>
<entry></entry>
<entry>reserved (can be function)</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
<row>
<entry><token>SIMPLE</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry></entry>
</row>
......@@ -2596,7 +2632,7 @@
</row>
<row>
<entry><token>SMALLINT</token></entry>
<entry></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -2672,6 +2708,12 @@
<entry>reserved</entry>
<entry></entry>
</row>
<row>
<entry><token>STABLE</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>START</token></entry>
<entry>non-reserved</entry>
......@@ -2714,6 +2756,18 @@
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>STORAGE</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>STRICT</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>STRUCTURE</token></entry>
<entry></entry>
......@@ -2914,7 +2968,7 @@
</row>
<row>
<entry><token>TREAT</token></entry>
<entry></entry>
<entry>non-reserved (cannot be function or type)</entry>
<entry>reserved</entry>
<entry></entry>
</row>
......@@ -3046,7 +3100,7 @@
</row>
<row>
<entry><token>USAGE</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......@@ -3092,6 +3146,12 @@
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>VALIDATOR</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>VALUE</token></entry>
<entry></entry>
......@@ -3140,6 +3200,12 @@
<entry>reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>VOLATILE</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>WHEN</token></entry>
<entry>reserved</entry>
......@@ -3178,7 +3244,7 @@
</row>
<row>
<entry><token>WRITE</token></entry>
<entry></entry>
<entry>non-reserved</entry>
<entry>reserved</entry>
<entry>reserved</entry>
</row>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.100 2002/11/10 00:14:22 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.101 2002/11/11 20:14:03 petere Exp $
-->
<chapter id="libpq">
......@@ -2139,22 +2139,23 @@ for information on correct values for these environment variables.
<primary>password</primary>
<secondary>.pgpass</secondary>
</indexterm>
<filename>$HOME/.pgpass</filename> is a file that can contain passwords
to be used if the connection requires a password. This file should have the
format:
<screen>
The file <filename>.pgpass</filename> in the home directory is a file
that can contain passwords to be used if the connection requires a
password. This file should have the format:
<synopsis>
<replaceable>hostname</replaceable>:<replaceable>port</replaceable>:<replaceable>database</replaceable>:<replaceable>username</replaceable>:<replaceable>password</replaceable>
</screen>
</synopsis>
Any of these may be a literal name, or <literal>*</literal>, which matches
anything. The first match will be used so put more specific entries first.
Entries with <literal>:</literal> or <literal>\</literal> should be escaped
with <literal>\</literal>.
</para>
<para>
The permissions on <filename>$HOME/.pgpass</filename> must disallow any
The permissions on <filename>.pgpass</filename> must disallow any
access to world or group; achieve this by the command
<command>chmod 0600 $HOME/.pgaccess</command>.
<command>chmod 0600 .pgaccess</command>.
If the permissions are less strict than this, the file will be ignored.
</para>
</sect1>
<sect1 id="libpq-threading">
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.19 2002/09/21 18:32:53 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.20 2002/11/11 20:14:03 petere Exp $
-->
<chapter id="maintenance">
......@@ -13,7 +13,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.19 2002/09/21 18:32:53
a regular basis to keep a <productname>PostgreSQL</productname>
installation running smoothly. The tasks discussed here are repetitive
in nature and can easily be automated using standard Unix tools such
as <filename>cron</filename> scripts. But it is the database
as <application>cron</application> scripts. But it is the database
administrator's responsibility to set up appropriate scripts, and to
check that they execute successfully.
</para>
......@@ -104,7 +104,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.19 2002/09/21 18:32:53
<command>UPDATE</> or <command>DELETE</> of a row does not
immediately remove the old <firstterm>tuple</> (version of the row).
This approach is necessary to gain the benefits of multiversion
concurrency control (see the <citetitle>User's Guide</>): the tuple
concurrency control (see the &cite-user;): the tuple
must not be deleted while it is still potentially visible to other
transactions. But eventually, an outdated or deleted tuple is no
longer of interest to any transaction. The space it occupies must be
......@@ -206,7 +206,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.19 2002/09/21 18:32:53
Although per-column tweaking of <command>ANALYZE</> frequency may not be
very productive, you may well find it worthwhile to do per-column
adjustment of the level of detail of the statistics collected by
<command>ANALYZE</>. Columns that are heavily used in WHERE clauses
<command>ANALYZE</>. Columns that are heavily used in <literal>WHERE</> clauses
and have highly irregular data distributions may require a finer-grain
data histogram than other columns. See <command>ALTER TABLE SET
STATISTICS</>.
......@@ -299,7 +299,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.19 2002/09/21 18:32:53
is exactly one billion transactions: if you wait longer, it's possible
that a tuple that was not quite old enough to be reassigned last time
is now more than two billion transactions old and has wrapped around
into the future --- ie, is lost to you. (Of course, it'll reappear
into the future --- i.e., is lost to you. (Of course, it'll reappear
after another two billion transactions, but that's no help.)
</para>
......@@ -311,17 +311,17 @@ $Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.19 2002/09/21 18:32:53
statistics in the system table <filename>pg_database</>. In particular,
the <filename>datfrozenxid</> field of a database's
<filename>pg_database</> row is updated at the completion of any
database-wide vacuum operation (ie, <command>VACUUM</> that does not
database-wide vacuum operation (i.e., <command>VACUUM</> that does not
name a specific table). The value stored in this field is the freeze
cutoff XID that was used by that <command>VACUUM</> command. All normal
XIDs older than this cutoff XID are guaranteed to have been replaced by
<literal>FrozenXID</> within that database. A convenient way to
examine this information is to execute the query
<informalexample>
<programlisting>
SELECT datname, age(datfrozenxid) FROM pg_database;
</programlisting>
</informalexample>
The <literal>age</> column measures the number of transactions from the
cutoff XID to the current transaction's XID.
</para>
......@@ -336,7 +336,7 @@ SELECT datname, age(datfrozenxid) FROM pg_database;
each database-wide <command>VACUUM</> automatically delivers a warning
if there are any <filename>pg_database</> entries showing an
<literal>age</> of more than 1.5 billion transactions, for example:
<informalexample>
<programlisting>
play=# vacuum;
WARNING: Some databases have not been vacuumed in 1613770184 transactions.
......@@ -344,7 +344,6 @@ WARNING: Some databases have not been vacuumed in 1613770184 transactions.
or you may have a wraparound failure.
VACUUM
</programlisting>
</informalexample>
</para>
<para>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/manage-ag.sgml,v 2.22 2002/10/24 17:48:54 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/manage-ag.sgml,v 2.23 2002/11/11 20:14:03 petere Exp $
-->
<chapter id="managing-databases">
......@@ -27,7 +27,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/manage-ag.sgml,v 2.22 2002/10/24 17:48:54 p
database within the installation.) More accurately, a database is
a collection of schemas and the schemas contain the tables,
functions, etc. So the full hierarchy is:
server-database-schema-table (or something else instead of a
server, database, schema, table (or something else instead of a
table).
</para>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/queries.sgml,v 1.18 2002/10/20 05:05:46 tgl Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/queries.sgml,v 1.19 2002/11/11 20:14:03 petere Exp $ -->
<chapter id="queries">
<title>Queries</title>
......@@ -668,7 +668,7 @@ SELECT <replaceable>select_list</replaceable>
order in which the columns are listed does not matter. The
purpose is to reduce each group of rows sharing common values into
one group row that is representative of all rows in the group.
This is done to eliminate redundancy in the output and/or obtain
This is done to eliminate redundancy in the output and/or compute
aggregates that apply to these groups. For instance:
<screen>
<prompt>=></> <userinput>SELECT * FROM test1;</>
......@@ -694,7 +694,12 @@ SELECT <replaceable>select_list</replaceable>
In the second query, we could not have written <literal>SELECT *
FROM test1 GROUP BY x</literal>, because there is no single value
for the column <literal>y</> that could be associated with each
group. In general, if a table is grouped, columns that are not
group. The grouped-by columns can be referenced in the select list since
they have a known constant value per group.
</para>
<para>
In general, if a table is grouped, columns that are not
used in the grouping cannot be referenced except in aggregate
expressions. An example with aggregate expressions is:
<screen>
......@@ -712,11 +717,6 @@ SELECT <replaceable>select_list</replaceable>
linkend="functions-aggregate">.
</para>
<para>
The grouped-by columns can be referenced in the select list since
they have a known constant value per group.
</para>
<tip>
<para>
Grouping without aggregate expressions effectively calculates the
......@@ -740,7 +740,7 @@ SELECT product_id, p.name, (sum(s.units) * p.price) AS sales
in the <literal>GROUP BY</> clause since they are referenced in
the query select list. (Depending on how exactly the products
table is set up, name and price may be fully dependent on the
product ID, so the additional groups could theoretically be
product ID, so the additional groupings could theoretically be
unnecessary, but this is not implemented yet.) The column
<literal>s.units</> does not have to be in the <literal>GROUP
BY</> list since it is only used in an aggregate expression
......@@ -828,7 +828,7 @@ SELECT product_id, p.name, (sum(s.units) * (p.price - p.cost)) AS profit
</para>
<sect2 id="queries-select-list-items">
<title>Select List Items</title>
<title>Select-List Items</title>
<para>
The simplest kind of select list is <literal>*</literal> which
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.27 2002/10/24 17:48:54 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.28 2002/11/11 20:14:03 petere Exp $
-->
<chapter id="tutorial-sql">
......@@ -13,7 +13,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.27 2002/10/24 17:48:54 peter
<acronym>SQL</acronym> to perform simple operations. This
tutorial is only intended to give you an introduction and is in no
way a complete tutorial on <acronym>SQL</acronym>. Numerous books
have been written on <acronym>SQL92</acronym>, including <xref
have been written on <acronym>SQL</acronym>, including <xref
linkend="MELT93"> and <xref linkend="DATE97">.
You should be aware that some <productname>PostgreSQL</productname>
language features are extensions to the standard.
......@@ -44,7 +44,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.27 2002/10/24 17:48:54 peter
The <literal>\i</literal> command reads in commands from the
specified file. The <literal>-s</literal> option puts you in
single step mode which pauses before sending each query to the
single step mode which pauses before sending each statement to the
server. The commands used in this section are in the file
<filename>basics.sql</filename>.
</para>
......@@ -502,7 +502,7 @@ SELECT *
join operator will have each of its rows in the output at least
once, whereas the table on the right will only have those rows
output that match some row of the left table. When outputting a
left-table row for which there is no right-table match, empty (NULL)
left-table row for which there is no right-table match, empty (null)
values are substituted for the right-table columns.
</para>
......@@ -601,7 +601,7 @@ SELECT max(temp_lo) FROM weather;
<para>
<indexterm><primary>subquery</primary></indexterm>
If we want to know what city (or cities) that reading occurred in,
If we wanted to know what city (or cities) that reading occurred in,
we might try
<programlisting>
......@@ -615,7 +615,7 @@ SELECT city FROM weather WHERE temp_lo = max(temp_lo); <lineannotation>WRONG
go into the aggregation stage; so it has to be evaluated before
aggregate functions are computed.)
However, as is often the case
the query can be restated to accomplish the intended result; here
the query can be restated to accomplish the intended result, here
by using a <firstterm>subquery</firstterm>:
<programlisting>
......@@ -630,9 +630,9 @@ SELECT city FROM weather
(1 row)
</screen>
This is OK because the sub-select is an independent computation
This is OK because the subquery is an independent computation
that computes its own aggregate separately from what is happening
in the outer select.
in the outer query.
</para>
<para>
......@@ -684,10 +684,18 @@ SELECT city, max(temp_lo)
<programlisting>
SELECT city, max(temp_lo)
FROM weather
WHERE city LIKE 'S%'
WHERE city LIKE 'S%'<co id="co.tutorial-agg-like">
GROUP BY city
HAVING max(temp_lo) < 40;
</programlisting>
<calloutlist>
<callout arearefs="co.tutorial-agg-like">
<para>
The <literal>LIKE</literal> operator does pattern matching and
is explained in the &cite-user;.
</para>
</callout>
</calloutlist>
</para>
<para>
......@@ -729,7 +737,7 @@ SELECT city, max(temp_lo)
You can update existing rows using the
<command>UPDATE</command> command.
Suppose you discover the temperature readings are
all off by 2 degrees as of November 28, you may update the
all off by 2 degrees as of November 28. You may update the
data as follows:
<programlisting>
......@@ -762,8 +770,8 @@ SELECT * FROM weather;
</indexterm>
<para>
Suppose you are no longer interested in the weather of Hayward,
then you can do the following to delete those rows from the table.
Suppose you are no longer interested in the weather of Hayward.
Then you can do the following to delete those rows from the table.
Deletions are performed using the <command>DELETE</command>
command:
<programlisting>
......@@ -786,7 +794,7 @@ SELECT * FROM weather;
</para>
<para>
One should be wary of queries of the form
One should be wary of statements of the form
<synopsis>
DELETE FROM <replaceable>tablename</replaceable>;
</synopsis>
......
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.26 2002/10/24 17:48:54 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.27 2002/11/11 20:14:04 petere Exp $
-->
<chapter id="tutorial-start">
......@@ -281,10 +281,10 @@ createdb: database creation failed
<listitem>
<para>
Using an existing graphical frontend tool like
<application>PgAccess</application> or
<application>ApplixWare</application> (via
<acronym>ODBC</acronym>) to create and manipulate a database.
These possibilities are not covered in this tutorial.
<application>PgAccess</application> or an office suite with
<acronym>ODBC</acronym> support to create and manipulate a
database. These possibilities are not covered in this
tutorial.
</para>
</listitem>
......
This diff is collapsed.
<chapter Id="typeconv">
<title>Type Conversion</title>
<sect1 id="typeconv-intro">
<title>Introduction</title>
<para>
<acronym>SQL</acronym> queries can, intentionally or not, require
mixing of different data types in the same expression.
......@@ -29,10 +26,9 @@ operators.
</para>
<para>
The <citetitle>Programmer's Guide</citetitle> has more details on the exact algorithms used for
The &cite-programmer; has more details on the exact algorithms used for
implicit type conversion and coercion.
</para>
</sect1>
<sect1 id="typeconv-overview">
<title>Overview</title>
......@@ -41,7 +37,7 @@ implicit type conversion and coercion.
<acronym>SQL</acronym> is a strongly typed language. That is, every data item
has an associated data type which determines its behavior and allowed usage.
<productname>PostgreSQL</productname> has an extensible type system that is
much more general and flexible than other <acronym>RDBMS</acronym> implementations.
much more general and flexible than other <acronym>SQL</acronym> implementations.
Hence, most type conversion behavior in <productname>PostgreSQL</productname>
should be governed by general rules rather than by <foreignphrase>ad hoc</> heuristics, to allow
mixed-type expressions to be meaningful even with user-defined types.
......@@ -142,13 +138,13 @@ conventions for the <acronym>SQL</acronym> standard native types such as
</para>
<para>
The <productname>PostgreSQL</productname> parser uses the convention that all
type conversion functions take a single argument of the source type and are
named with the same name as the target type. Any function meeting these
criteria is considered to be a valid conversion function, and may be used
by the parser as such. This simple assumption gives the parser the power
to explore type conversion possibilities without hardcoding, allowing
extended user-defined types to use these same features transparently.
The system catalogs store information about which conversions, called
<firstterm>casts</firstterm>, between data types are valid, and how to
perform those conversions. Additional casts can be added by the user
with the <command>CREATE CAST</command> command. (This is usually
done in conjunction with defining new data types. The set of casts
between the built-in types has been carefully crafted and should not
be altered.)
</para>
<para>
......@@ -169,7 +165,7 @@ types.
<para>
All type conversion rules are designed with several principles in mind:
<itemizedlist mark="bullet" spacing="compact">
<itemizedlist>
<listitem>
<para>
Implicit conversions should never have surprising or unpredictable outcomes.
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/user-manag.sgml,v 1.17 2002/10/24 17:48:54 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/user-manag.sgml,v 1.18 2002/11/11 20:14:04 petere Exp $
-->
<chapter id="user-manag">
......@@ -129,7 +129,7 @@ dropuser <replaceable>name</replaceable>
<para>
A password is only significant if the client authentication
method requires the user to supply a password when connecting
to the database. At present, the <option>password</>,
to the database. The <option>password</>,
<option>md5</>, and <option>crypt</> authentication methods
make use of passwords. Database passwords are separate from
operating system passwords. Specify a password upon user
......@@ -156,7 +156,7 @@ dropuser <replaceable>name</replaceable>
ALTER USER myname SET enable_indexscan TO off;
</programlisting>
This will save the setting (but not set it immediately) and in
subsequent connections it will appear as though <literal>SET geqo
subsequent connections it will appear as though <literal>SET enable_indexscan
TO off;</literal> had been called right before the session started.
You can still alter this setting during the session; it will only
be the default. To undo any such setting, use <literal>ALTER USER
......@@ -205,7 +205,7 @@ ALTER GROUP <replaceable>name</replaceable> DROP USER <replaceable>uname1</repla
<literal>USAGE</>, and <literal>ALL PRIVILEGES</>. For more
information on the different types of privileges support by
<productname>PostgreSQL</productname>, refer to the
<command>GRANT</command> reference manual. The right to modify or
<command>GRANT</command> page in the &cite-reference;. The right to modify or
destroy an object is always the privilege of the owner only. To
assign privileges, the <command>GRANT</command> command is
used. So, if <literal>joe</literal> is an existing user, and
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment