Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
30e355fc
Commit
30e355fc
authored
Apr 07, 2000
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix path to initdb in installation instructions.
General cleanup for 7.0.
parent
b2096a55
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1304 additions
and
967 deletions
+1304
-967
doc/src/sgml/advanced.sgml
doc/src/sgml/advanced.sgml
+41
-19
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+103
-3
doc/src/sgml/install.sgml
doc/src/sgml/install.sgml
+584
-550
doc/src/sgml/intro.sgml
doc/src/sgml/intro.sgml
+14
-10
doc/src/sgml/legal.sgml
doc/src/sgml/legal.sgml
+11
-3
doc/src/sgml/notation.sgml
doc/src/sgml/notation.sgml
+17
-10
doc/src/sgml/ports.sgml
doc/src/sgml/ports.sgml
+27
-26
doc/src/sgml/query.sgml
doc/src/sgml/query.sgml
+72
-49
doc/src/sgml/sql.sgml
doc/src/sgml/sql.sgml
+94
-48
doc/src/sgml/start.sgml
doc/src/sgml/start.sgml
+337
-246
doc/src/sgml/y2k.sgml
doc/src/sgml/y2k.sgml
+4
-3
No files found.
doc/src/sgml/advanced.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.
9 2000/03/31 03:27:40
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.
10 2000/04/07 13:30:58
thomas Exp $
-->
-->
<chapter id="advanced">
<chapter id="advanced">
...
@@ -106,10 +106,10 @@ SELECT c.name, c.altitude
...
@@ -106,10 +106,10 @@ SELECT c.name, c.altitude
Here the <quote>*</quote> after cities indicates that the query should
Here the <quote>*</quote> after cities indicates that the query should
be run over cities and all classes below cities in the
be run over cities and all classes below cities in the
inheritance hierarchy. Many of the commands that we
inheritance hierarchy. Many of the commands that we
have already discussed (<command>
select
</command>,
have already discussed (<command>
SELECT
</command>,
<command>
update</command> and <command>delete
</command>)
<command>
UPDATE</command> and <command>DELETE
</command>)
support this <quote>*</quote> notation, as do others, like
support this <quote>*</quote> notation, as do others, like
<command>
alter
</command>.
<command>
ALTER
</command>.
</para>
</para>
</sect1>
</sect1>
...
@@ -118,7 +118,8 @@ SELECT c.name, c.altitude
...
@@ -118,7 +118,8 @@ SELECT c.name, c.altitude
<para>
<para>
One of the tenets of the relational model is that the
One of the tenets of the relational model is that the
attributes of a relation are atomic. <productname>Postgres</productname> does not
attributes of a relation are atomic.
<productname>Postgres</productname> does not
have this restriction; attributes can themselves contain
have this restriction; attributes can themselves contain
sub-values that can be accessed from the query
sub-values that can be accessed from the query
language. For example, you can create attributes that
language. For example, you can create attributes that
...
@@ -129,7 +130,8 @@ SELECT c.name, c.altitude
...
@@ -129,7 +130,8 @@ SELECT c.name, c.altitude
<title>Arrays</title>
<title>Arrays</title>
<para>
<para>
<productname>Postgres</productname> allows attributes of an instance to be defined
<productname>Postgres</productname> allows attributes of an
instance to be defined
as fixed-length or variable-length multi-dimensional
as fixed-length or variable-length multi-dimensional
arrays. Arrays of any base type or user-defined type
arrays. Arrays of any base type or user-defined type
can be created. To illustrate their use, we first create a
can be created. To illustrate their use, we first create a
...
@@ -149,11 +151,14 @@ CREATE TABLE SAL_EMP (
...
@@ -149,11 +151,14 @@ CREATE TABLE SAL_EMP (
a <firstterm>text</firstterm> string (name), a one-dimensional
a <firstterm>text</firstterm> string (name), a one-dimensional
array of <firstterm>int4</firstterm>
array of <firstterm>int4</firstterm>
(pay_by_quarter), which represents the employee's
(pay_by_quarter), which represents the employee's
salary by quarter and a two-dimensional array of <firstterm>text</firstterm>
salary by quarter and a two-dimensional array of
<firstterm>text</firstterm>
(schedule), which represents the employee's weekly
(schedule), which represents the employee's weekly
schedule. Now we do some <firstterm>INSERTS</firstterm>s; note that when
schedule. Now we do some <firstterm>INSERTS</firstterm>s;
note that when
appending to an array, we enclose the values within
appending to an array, we enclose the values within
braces and separate them by commas. If you know <firstterm>C</firstterm>,
braces and separate them by commas. If you know
<firstterm>C</firstterm>,
this is not unlike the syntax for initializing structures.
this is not unlike the syntax for initializing structures.
<programlisting>
<programlisting>
...
@@ -168,7 +173,8 @@ INSERT INTO SAL_EMP
...
@@ -168,7 +173,8 @@ INSERT INTO SAL_EMP
'{{"talk", "consult"}, {"meeting"}}');
'{{"talk", "consult"}, {"meeting"}}');
</programlisting>
</programlisting>
By default, <productname>Postgres</productname> uses the "one-based" numbering
By default, <productname>Postgres</productname> uses the
"one-based" numbering
convention for arrays -- that is, an array of n elements
convention for arrays -- that is, an array of n elements
starts with array[1] and ends with array[n].
starts with array[1] and ends with array[n].
Now, we can run some queries on SAL_EMP. First, we
Now, we can run some queries on SAL_EMP. First, we
...
@@ -228,6 +234,11 @@ SELECT SAL_EMP.schedule[1:2][1:1]
...
@@ -228,6 +234,11 @@ SELECT SAL_EMP.schedule[1:2][1:1]
</sect2>
</sect2>
</sect1>
</sect1>
<!--
We haven't had Time Travel for two or three years, so let's stop
mentioning it. - thomas 2000-04-02
<sect1>
<sect1>
<title>Time Travel</title>
<title>Time Travel</title>
...
@@ -240,21 +251,27 @@ SELECT SAL_EMP.schedule[1:2][1:1]
...
@@ -240,21 +251,27 @@ SELECT SAL_EMP.schedule[1:2][1:1]
</para>
</para>
<para>
<para>
New features such as triggers allow one to mimic the behavior of time travel when desired, without
New features such as triggers allow one to mimic the behavior of
incurring the overhead when it is not needed (for most users, this is most of the time).
time travel when desired, without
See examples in the <filename>contrib</filename> directory for more information.
incurring the overhead when it is not needed (for most users, this
is most of the time).
See examples in the <filename>contrib</filename> directory for
more information.
</para>
</para>
<note>
<note>
<title>Time travel is deprecated</title>
<title>Time travel is deprecated</title>
<para>
<para>
The remaining text in this section is retained only until it can be rewritten in the context
The remaining text in this section is retained only until it can
of new techniques to accomplish the same purpose. Volunteers? - thomas 1998-01-12
be rewritten in the context
of new techniques to accomplish the same purpose.
Volunteers? - thomas 1998-01-12
</para>
</para>
</note>
</note>
<para>
<para>
<productname>Postgres</productname> supports the notion of time travel. This feature
<productname>Postgres</productname> supports the notion of time
travel. This feature
allows a user to run historical queries. For
allows a user to run historical queries. For
example, to find the current population of Mariposa
example, to find the current population of Mariposa
city, one would query:
city, one would query:
...
@@ -269,7 +286,8 @@ SELECT * FROM cities WHERE name = 'Mariposa';
...
@@ -269,7 +286,8 @@ SELECT * FROM cities WHERE name = 'Mariposa';
+---------+------------+----------+
+---------+------------+----------+
</programlisting>
</programlisting>
<productname>Postgres</productname> will automatically find the version of Mariposa's
<productname>Postgres</productname> will automatically find the
version of Mariposa's
record valid at the current time.
record valid at the current time.
One can also give a time range. For example to see the
One can also give a time range. For example to see the
past and present populations of Mariposa, one would
past and present populations of Mariposa, one would
...
@@ -313,18 +331,22 @@ SELECT name, population
...
@@ -313,18 +331,22 @@ SELECT name, population
abbreviated as ``[,].''
abbreviated as ``[,].''
</para>
</para>
</sect1>
</sect1>
-->
<sect1>
<sect1>
<title>More Advanced Features</title>
<title>More Advanced Features</title>
<para>
<para>
<productname>Postgres</productname> has many features not touched upon in this
<productname>Postgres</productname> has many features not touched
upon in this
tutorial introduction, which has been oriented toward newer users of
tutorial introduction, which has been oriented toward newer users of
<acronym>SQL</acronym>.
<acronym>SQL</acronym>.
These are discussed in more detail in both the User's and Programmer's Guides.
These are discussed in more detail in both the User's and
Programmer's Guides.
</para>
</para>
</sect1>
</sect1>
</chapter>
</chapter>
<!-- Keep this comment at the end of the file
<!-- Keep this comment at the end of the file
...
...
doc/src/sgml/func.sgml
View file @
30e355fc
...
@@ -88,10 +88,10 @@
...
@@ -88,10 +88,10 @@
<entry>abs(-17.4)</entry>
<entry>abs(-17.4)</entry>
</row>
</row>
<row>
<row>
<entry>
sqrt
(float8)</entry>
<entry>
degrees
(float8)</entry>
<entry>float8</entry>
<entry>float8</entry>
<entry>
square root
</entry>
<entry>
radians to degrees
</entry>
<entry>
sqrt(2.0
)</entry>
<entry>
degrees(0.5
)</entry>
</row>
</row>
<row>
<row>
<entry>exp(float8)</entry>
<entry>exp(float8)</entry>
...
@@ -111,18 +111,36 @@
...
@@ -111,18 +111,36 @@
<entry>base 10 logarithm</entry>
<entry>base 10 logarithm</entry>
<entry>log(2.0)</entry>
<entry>log(2.0)</entry>
</row>
</row>
<row>
<entry>pi()</entry>
<entry>float8</entry>
<entry>fundamental constant</entry>
<entry>pi()</entry>
</row>
<row>
<row>
<entry>pow(float8,float8)</entry>
<entry>pow(float8,float8)</entry>
<entry>float8</entry>
<entry>float8</entry>
<entry>raise a number to the specified exponent</entry>
<entry>raise a number to the specified exponent</entry>
<entry>pow(2.0, 16.0)</entry>
<entry>pow(2.0, 16.0)</entry>
</row>
</row>
<row>
<entry>radians(float8)</entry>
<entry>float8</entry>
<entry>degrees to radians</entry>
<entry>radians(45.0)</entry>
</row>
<row>
<row>
<entry>round(float8)</entry>
<entry>round(float8)</entry>
<entry>float8</entry>
<entry>float8</entry>
<entry>round to nearest integer</entry>
<entry>round to nearest integer</entry>
<entry>round(42.4)</entry>
<entry>round(42.4)</entry>
</row>
</row>
<row>
<entry>sqrt(float8)</entry>
<entry>float8</entry>
<entry>square root</entry>
<entry>sqrt(2.0)</entry>
</row>
<row>
<row>
<entry>trunc(float8)</entry>
<entry>trunc(float8)</entry>
<entry>float8</entry>
<entry>float8</entry>
...
@@ -156,6 +174,88 @@
...
@@ -156,6 +174,88 @@
Most of the functions listed for FLOAT8 are also available for
Most of the functions listed for FLOAT8 are also available for
type NUMERIC.
type NUMERIC.
</para>
</para>
<para>
<table tocentry="1">
<title>Transcendental Mathematical Functions</title>
<tgroup cols="4">
<thead>
<row>
<entry>Function</entry>
<entry>Returns</entry>
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry>acos(float8)</entry>
<entry>float8</entry>
<entry>arccosine</entry>
<entry>acos(10.0)</entry>
</row>
<row>
<entry>asin(float8)</entry>
<entry>float8</entry>
<entry>arcsine</entry>
<entry>asin(10.0)</entry>
</row>
<row>
<entry>atan(float8)</entry>
<entry>float8</entry>
<entry>arctangent</entry>
<entry>atan(10.0)</entry>
</row>
<row>
<entry>atan2(float8,float8)</entry>
<entry>float8</entry>
<entry>arctangent</entry>
<entry>atan3(10.0,20.0)</entry>
</row>
<row>
<entry>cos(float8)</entry>
<entry>float8</entry>
<entry>cosine</entry>
<entry>cos(0.4)</entry>
</row>
<row>
<entry>cot(float8)</entry>
<entry>float8</entry>
<entry>cotangent</entry>
<entry>cot(20.0)</entry>
</row>
<row>
<entry>sin(float8)</entry>
<entry>float8</entry>
<entry>sine</entry>
<entry>cos(0.4)</entry>
</row>
<row>
<entry>cos(float8)</entry>
<entry>float8</entry>
<entry>cosine</entry>
<entry>cos(0.4)</entry>
</row>
<row>
<entry>cos(float8)</entry>
<entry>float8</entry>
<entry>cosine</entry>
<entry>cos(0.4)</entry>
</row>
<row>
<entry>cos(float8)</entry>
<entry>float8</entry>
<entry>cosine</entry>
<entry>cos(0.4)</entry>
</row>
<row>
<entry>cos(float8)</entry>
<entry>float8</entry>
<entry>cosine</entry>
<entry>cos(0.4)</entry>
</row>
</sect1>
</sect1>
<sect1>
<sect1>
...
...
doc/src/sgml/install.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/install.sgml,v 1.3
8 2000/03/31 15:00:14 tgl
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/install.sgml,v 1.3
9 2000/04/07 13:30:58 thomas
Exp $
-->
-->
<
Chapter I
d="install">
<
chapter i
d="install">
<
Title>Installation</T
itle>
<
title>Installation</t
itle>
<
A
bstract>
<
a
bstract>
<
P
ara>
<
p
ara>
Installation instructions for
Installation instructions for
<
ProductName>PostgreSQL</ProductN
ame> 7.0.
<
productname>PostgreSQL</productn
ame> 7.0.
</
P
ara>
</
p
ara>
</
A
bstract>
</
a
bstract>
<
P
ara>
<
p
ara>
If you haven't gotten the <
ProductName>PostgreSQL</ProductN
ame> distribution,
If you haven't gotten the <
productname>PostgreSQL</productn
ame> distribution,
get it from <
ULink url="ftp://ftp.postgresql.org">ftp.postgresql.org</UL
ink>,
get it from <
ulink url="ftp://ftp.postgresql.org">ftp.postgresql.org</ul
ink>,
then unpack it:
then unpack it:
<ProgramListing>
gunzip postgresql-7.0.tar.gz
<programlisting>
tar -xf postgresql-7.0.tar
> gunzip postgresql-7.0.tar.gz
mv postgresql-7.0 /usr/src
> tar -xf postgresql-7.0.tar
</ProgramListing>
> mv postgresql-7.0 /usr/src
</Para>
</programlisting>
</para>
<Sect1>
<Title>Before you start</Title>
<sect1>
<title>Before you start</title>
<Para>
Building <Productname>PostgreSQL</Productname> requires <acronym>GNU</acronym>
<para>
<Application>make</Application>. It will <Emphasis>not</Emphasis>
Building <productname>PostgreSQL</productname> requires <acronym>GNU</acronym>
work with other <Application>make</Application> programs. On GNU/Linux systems
<application>make</application>. It will <emphasis>not</emphasis>
work with other <application>make</application> programs. On GNU/Linux systems
GNU make is the default tool, on other systems you may find that
GNU make is the default tool, on other systems you may find that
GNU <Application>make</Application> is installed under the name <Quote>gmake</Quote>.
GNU <application>make</application> is installed under the name
<quote>gmake</quote>.
We will use that name from now on to indicate <acronym>GNU</acronym>
We will use that name from now on to indicate <acronym>GNU</acronym>
<
Application>make</A
pplication>, no matter what name it has on your system.
<
application>make</a
pplication>, no matter what name it has on your system.
To test for <acronym>GNU</acronym> <
Application>make</A
pplication> enter
To test for <acronym>GNU</acronym> <
application>make</a
pplication> enter
<programlisting>
<programlisting>
<userinput>gmake --version</userinput>
>
<userinput>gmake --version</userinput>
</programlisting>
</programlisting>
If you need to get <acronym>GNU</acronym> <Application>make</Application>, you can
If you need to get <acronym>GNU</acronym>
find it at <ULink url="ftp://ftp.gnu.org">ftp://ftp.gnu.org</ULink>.
<application>make</application>, you can
</Para>
find it at <ulink url="ftp://ftp.gnu.org">ftp://ftp.gnu.org</ulink>.
</para>
<
P
ara>
<
p
ara>
Up to date information on supported platforms is at
Up to date information on supported platforms is at
<ulink url="http://www.postgresql.org/docs/admin/ports.htm">
<ulink url="http://www.postgresql.org/docs/admin/ports.htm">
http://www.postgresql.org/docs/admin/ports.htm</ulink>.
http://www.postgresql.org/docs/admin/ports.htm</ulink>.
In general, most Unix-compatible platforms with modern libraries should be able to run
In general, most Unix-compatible platforms with modern libraries
<ProductName>PostgreSQL</ProductName>. In the <filename>doc</filename> subdirectory
should be able to run
<productname>PostgreSQL</productname>. In the
<filename>doc</filename> subdirectory
of the distribution are several platform-specific FAQ and README documents you
of the distribution are several platform-specific FAQ and README documents you
might wish to consult if you are having trouble.
might wish to consult if you are having trouble.
</para>
</para>
<para>
<para>
Although the minimum required memory for running <ProductName>PostgreSQL</ProductName>
Although the minimum required memory for running
can be as little as 8MB, there are noticeable speed improvements when expanding memory
<productname>PostgreSQL</productname>
can be as little as 8MB, there are noticeable speed improvements
when expanding memory
up to 96MB or beyond. The rule is you can never have too much memory.
up to 96MB or beyond. The rule is you can never have too much memory.
</para>
</para>
<
P
ara>
<
p
ara>
Check that you have sufficient disk space. You will need about
Check that you have sufficient disk space. You will need about
30 Mbytes for the source tree during compilation and about 5 Mbytes for
30 Mbytes for the source tree during compilation and about 5 Mbytes for
the installation directory. An empty database takes about 1 Mbyte, otherwise
the installation directory. An empty database takes about 1 Mbyte, otherwise
they take about five times the amount of space that a flat text file with the
they take about five times the amount of space that a flat text file with the
same data would take. If you run the regression tests you will temporarily need
same data would take. If you run the regression tests you will temporarily need
an extra 20MB.
an extra 20MB.
</
P
ara>
</
p
ara>
<
P
ara>
<
p
ara>
To check for disk space, use
To check for disk space, use
<programlisting>
<programlisting>
df -k
>
df -k
</programlisting>
</programlisting>
</para>
</para>
<para>
<para>
Considering today's prices for hard disks, getting a large and fast hard disk should
Considering today's prices for hard disks, getting a large and
fast hard disk should
probably be in your plans before putting a database into production use.
probably be in your plans before putting a database into production use.
</para>
</para>
</Sect1>
</sect1>
<Sect1>
<sect1>
<Title>Installation Procedure</Title>
<title>Installation Procedure</title>
<Procedure>
<procedure>
<Title><ProductName>PostgreSQL</ProductName> Installation</Title>
<title><productname>PostgreSQL</productname> Installation</title>
<Para>
<para>
For a fresh install or upgrading from previous releases of
For a fresh install or upgrading from previous releases of
<ProductName>PostgreSQL</ProductName>:
<productname>PostgreSQL</productname>:
</Para>
</para>
<Step Performance="optional">
<step performance="optional">
<Para>
<para>
Create the <ProductName>PostgreSQL</ProductName> superuser account.
Create the <productname>PostgreSQL</productname> superuser account.
This is the user the server will run as. For production use you
This is the user the server will run as. For production use you
should create a separate, unprivileged account (<literal>postgres</literal> is
should create a separate, unprivileged account
commonly used). If you do not have root access or just want to play around,
(<literal>postgres</literal> is
your own user account is enough.
commonly used). If you do not have root access or just want to play around,
</para>
your own user account is enough.
<para>
</para>
Running <ProductName>PostgreSQL</ProductName> as <literal>root</literal>, <literal>bin</literal>,
<para>
or any other account with special access rights is a security risk;
Running <productname>PostgreSQL</productname> as
<emphasis>don't do it</emphasis>. The postmaster will in fact refuse
<literal>tera</literal>teral>, <literal>bin</literal>,
to start as root.
or any other account with special access rights is a security risk;
</para>
<emphasis>don't do it</emphasis>. The postmaster will in fact refuse
<Para>
to start as root.
You need not do the building and installation itself under this account
</para>
(although you can). You will be told when you need to login as the
<para>
database superuser.
You need not do the building and installation itself under this account
</Para>
(although you can). You will be told when you need to login as the
</Step>
database superuser.
</para>
<Step Performance="required">
</step>
<Para>
Configure the source code for your system. It is this step at which
<step performance="required">
you can specify your actual installation path for the build process
<para>
and make choices about what gets installed. Change into the <filename>src</filename>
Configure the source code for your system. It is this step at which
subdirectory and type:
you can specify your actual installation path for the build process
<ProgramListing>
and make choices about what gets installed. Change into the
./configure
<filename>src</filename>
</ProgramListing>
subdirectory and type:
followed by any options you might want to give it. For a first installation
<programlisting>
you should be able to do fine without any.
> ./configure
For a complete list of options, type:
</programlisting>
<ProgramListing>
followed by any options you might want to give it. For a first installation
./configure --help
you should be able to do fine without any.
</ProgramListing>
For a complete list of options, type:
Some of the more commonly used ones are:
<programlisting>
<VariableList>
> ./configure --help
<varlistentry>
</programlisting>
<term>--prefix=BASEDIR</term>
Some of the more commonly used ones are:
<listitem>
<variablelist>
<para>
<varlistentry>
Selects a different base directory for the installation of
<term>--prefix=BASEDIR</term>
<ProductName>PostgreSQL</ProductName>. The default is <filename>/usr/local/pgsql</filename>.
<listitem>
</para>
<para>
</listitem>
Selects a different base directory for the installation of
</varlistentry>
<productname>PostgreSQL</productname>. The default is
<filename>/usr/local/pgsql</filename>.
<varlistentry>
</para>
<term>--enable-locale</term>
</listitem>
<listitem>
</varlistentry>
<para>
If you want to use locales.
<varlistentry>
</para>
<term>--enable-locale</term>
</listitem>
<listitem>
</varlistentry>
<para>
If you want to use locales.
<varlistentry>
</para>
<term>--enable-multibyte</term>
</listitem>
<listitem>
</varlistentry>
<para>
Allows the use of multibyte character encodings. This is primarily for
<varlistentry>
languages like Japanese, Korean, or Chinese.
<term>--enable-multibyte</term>
</para>
<listitem>
</listitem>
<para>
</varlistentry>
Allows the use of multibyte character encodings. This is primarily for
languages like Japanese, Korean, or Chinese.
<varlistentry>
</para>
<term>--with-perl</term>
</listitem>
<listitem>
</varlistentry>
<para>
Builds the Perl interface and plperl extension language.
<varlistentry>
Please note that the Perl interface needs to be
<term>--with-perl</term>
installed into the usual place for Perl modules (typically under
<listitem>
<filename>/usr/lib/perl</filename>), so you must have root access
<para>
to perform the installation step. (It is often easiest to leave out
Builds the Perl interface and plperl extension language.
<option>--with-perl</option> initially, and then build and install the
Please note that the Perl interface needs to be
Perl interface after completing the installation of PostgreSQL
installed into the usual place for Perl modules (typically under
itself.)
<filename>/usr/lib/perl</filename>), so you must have root access
</para>
to perform the installation step. (It is often easiest to leave out
</listitem>
<option>--with-perl</option> initially, and then build and install the
</varlistentry>
Perl interface after completing the installation of PostgreSQL
itself.)
<varlistentry>
</para>
<term>--with-odbc</term>
</listitem>
<listitem>
</varlistentry>
<para>
Builds the ODBC driver package.
<varlistentry>
</para>
<term>--with-odbc</term>
</listitem>
<listitem>
</varlistentry>
<para>
Builds the ODBC driver package.
<varlistentry>
</para>
<term>--with-tcl</term>
</listitem>
<listitem>
</varlistentry>
<para>
Builds interface libraries and programs requiring
<varlistentry>
Tcl/Tk, including libpgtcl, pgtclsh, and pgtksh.
<term>--with-tcl</term>
</para>
<listitem>
</listitem>
<para>
</varlistentry>
Builds interface libraries and programs requiring
</VariableList>
Tcl/Tk, including libpgtcl, pgtclsh, and pgtksh.
</para>
</Para>
</listitem>
</step>
</varlistentry>
</variablelist>
<Step Performance="required">
<Para>
</para>
Compile the program. Type
</step>
<ProgramListing>
gmake
<step performance="required">
</ProgramListing>
<para>
The compilation process can take anywhere from 10 minutes to an hour.
Compile the program. Type
Your mileage will most certainly vary. Remember to use GNU make.
<programlisting>
</Para>
> gmake
</programlisting>
<Para>
The compilation process can take anywhere from 10 minutes to an hour.
The last line displayed will hopefully be
Your mileage will most certainly vary. Remember to use GNU make.
<programlisting>
</para>
<para>
The last line displayed will hopefully be
<programlisting>
All of PostgreSQL is successfully made. Ready to install.
All of PostgreSQL is successfully made. Ready to install.
</programlisting>
</programlisting>
</Para>
</para>
</Step>
</step>
<Step Performance="optional">
<step performance="optional">
<Para>
<para>
If you want to test the newly built server before you install it,
If you want to test the newly built server before you install it,
you can run the regression tests at this point. The regression tests
you can run the regression tests at this point. The regression tests
are a test suite to verify that <ProductName>PostgreSQL</ProductName>
are a test suite to verify that <productname>PostgreSQL</productname>
runs on your machine in the way the developers expected it to.
runs on your machine in the way the developers expected it to.
For detailed instructions see <xref linkend="regress" endterm="regress-title">.
For detailed instructions see <xref endterm="regress-title"
(Be sure to use the "parallel regress test" method, since the sequential
linkend="regress">.
method only works with an already-installed server.)
(Be sure to use the "parallel regress test" method, since the sequential
</Para>
method only works with an already-installed server.)
</Step>
</para>
</step>
<Step Performance="required">
<Para>
<step performance="required">
If you are not upgrading an existing system then skip to
<para>
<xref linkend="continue">.
If you are not upgrading an existing system then skip to
</Para>
<xref linkend="continue">.
</para>
<Para>
You now need to back up your existing database.
<para>
To dump your fairly recent post-6.0 database installation, type
You now need to back up your existing database.
<programlisting>
To dump your fairly recent post-6.0 database installation, type
pg_dumpall > db.out
<programlisting>
</programlisting>
> pg_dumpall > db.out
If you wish to preserve object id's (oids), then use the -o
</programlisting>
option when running <application>pg_dumpall</application>.
If you wish to preserve object id's (oids), then use the -o
However, unless you have a
option when running <application>pg_dumpall</application>.
special reason for doing this (such as using OIDs as keys
However, unless you have a
in tables), don't do it.
special reason for doing this (such as using OIDs as keys
</Para>
in tables), don't do it.
</para>
<Para>
Make sure to use the <application>pg_dumpall</application>
<para>
command from the version you are currently running.
Make sure to use the <application>pg_dumpall</application>
7.0's <application>pg_dumpall</application> will not work on older databases.
command from the version you are currently running.
However, if you are still using 6.0, do not use the
7.0's <application>pg_dumpall</application> will not work on older databases.
<application>pg_dumpall</application> script from 6.0 or everything will be
However, if you are still using 6.0, do not use the
owned by the <ProductName>PostgreSQL</ProductName> superuser after you
<application>pg_dumpall</application> script from 6.0 or everything will be
reload. In that case
owned by the <productname>PostgreSQL</productname> superuser after you
you should grab <application>pg_dumpall</application> from a later
reload. In that case
6.x.x release.
you should grab <application>pg_dumpall</application> from a later
If you are upgrading from a version prior to
6.x.x release.
<ProductName>Postgres95</ProductName> v1.09 then you must back up your database,
If you are upgrading from a version prior to
install <ProductName>Postgres95</ProductName> v1.09, restore your database,
<productname>Postgres95</productname> v1.09 then you must back
then back it up again.
up your database,
</Para>
install <productname>Postgres95</productname> v1.09, restore your database,
then back it up again.
<caution>
</para>
<Para>
You must make sure that your database is not updated in the middle of
<caution>
your backup. If necessary, bring down postmaster, edit the permissions
<para>
in file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>
You must make sure that your database is not updated in the middle of
to allow only you on, then
your backup. If necessary, bring down postmaster, edit the permissions
bring <application>postmaster</application> back up.
in file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>
</Para>
to allow only you on, then
</caution>
bring <application>postmaster</application> back up.
</Step>
</para>
</caution>
<Step Performance="required">
</step>
<Para>
If you are upgrading an existing system then kill the database server now. Type
<step performance="required">
<ProgramListing>
<para>
ps ax | grep postmaster
If you are upgrading an existing system then kill the database
</ProgramListing>
server now. Type
or
<programlisting>
<ProgramListing>
> ps ax | grep postmaster
ps -e | grep postmaster
</programlisting>
</ProgramListing>
or
(It depends on your system which one of these two works. No harm can be done
<programlisting>
by typing the wrong one.)
> ps -e | grep postmaster
This should list the process numbers for a number of processes, similar
</programlisting>
to this:
(It depends on your system which one of these two works. No harm can be done
<ProgramListing>
by typing the wrong one.)
This should list the process numbers for a number of processes, similar
to this:
<programlisting>
263 ? SW 0:00 (postmaster)
263 ? SW 0:00 (postmaster)
777 p1 S 0:00 grep postmaster
777 p1 S 0:00 grep postmaster
</ProgramListing>
</programlisting>
Type the following line, with <replaceable>pid</replaceable>
Type the following line, with <replaceable>pid</replaceable>
replaced by the process id for process <literal>postmaster</literal>
replaced by the process id for process <literal>postmaster</literal>
(263 in the above case). (Do not use the id for the process "grep postmaster".)
(263 in the above case). (Do not use the id for the process
<programlisting>
"grep postmaster".)
kill <replaceable>pid</replaceable>
<programlisting>
</programlisting>
> kill <replaceable>pid</replaceable>
</Para>
</programlisting>
</para>
<tip>
<para>
<tip>
On systems which have <productname>PostgreSQL</productname> started at boot time, there
<para>
is probably a startup file that will accomplish the same thing. For example, on a
On systems which have <productname>PostgreSQL</productname>
Redhat Linux system one might find that
started at boot time, there
<programlisting>
is probably a startup file that will accomplish the same
/etc/rc.d/init.d/postgres.init stop
thing. For example, on a
</programlisting>
Redhat Linux system one might find that
works.
<programlisting>
</para>
> /etc/rc.d/init.d/postgres.init stop
</tip>
</programlisting>
works.
<Para>
</para>
Also move the old directories out of the way. Type the following:
</tip>
<programlisting>
mv /usr/local/pgsql /usr/local/pgsql.old
<para>
</programlisting>
Also move the old directories out of the way. Type the following:
(substitute your particular paths).
<programlisting>
</Para>
> mv /usr/local/pgsql /usr/local/pgsql.old
</programlisting>
</Step>
(substitute your particular paths).
</para>
<Step Performance="required" id="continue">
<Para>
</step>
Install the <ProductName>PostgreSQL</ProductName> executable files and
libraries. Type
<step performance="required" id="continue">
<ProgramListing>
<para>
gmake install
Install the <productname>PostgreSQL</productname> executable files and
</ProgramListing>
libraries. Type
</Para>
<programlisting>
<Para>
> gmake install
You should do this step as the user that you want the installed executables
</programlisting>
to be owned by. This does not have to be the same as the database superuser;
</para>
some people prefer to have the installed files be owned by root.
<para>
</Para>
You should do this step as the user that you want the installed executables
</Step>
to be owned by. This does not have to be the same as the database superuser;
some people prefer to have the installed files be owned by root.
<Step Performance="required">
</para>
<Para>
</step>
If necessary, tell your system how to find the new shared libraries.
How to do this varies between platforms. The most widely usable method
<step performance="required">
is to set the environment variable
<para>
<envar>LD_LIBRARY_PATH</envar>:
If necessary, tell your system how to find the new shared libraries.
<programlisting>
How to do this varies between platforms. The most widely usable method
LD_LIBRARY_PATH=/usr/local/pgsql/lib
is to set the environment variable
export LD_LIBRARY_PATH
<envar>LD_LIBRARY_PATH</envar>:
</programlisting>
<programlisting>
on sh, ksh, bash, zsh or
> LD_LIBRARY_PATH=/usr/local/pgsql/lib
<programlisting>
> export LD_LIBRARY_PATH
setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
</programlisting>
</programlisting>
on sh, ksh, bash, zsh or
on csh or tcsh.
<programlisting>
You might want to put this into a shell startup file such as
> setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
<filename>/etc/profile</filename>.
</programlisting>
</Para>
on csh or tcsh.
You might want to put this into a shell startup file such as
<Para>
<filename>/etc/profile</filename>.
On some systems the following is the preferred method, but you must have root
</para>
access. Edit file <filename>/etc/ld.so.conf</filename> to add a line
<programlisting>
<para>
<FileName>/usr/local/pgsql/lib</FileName>
On some systems the following is the preferred method, but you must have root
</programlisting>
access. Edit file <filename>/etc/ld.so.conf</filename> to add a line
Then run command <Command>/sbin/ldconfig</Command>.
<programlisting>
</Para>
<filename>/usr/local/pgsql/lib</filename>
</programlisting>
<Para>
Then run command <command>/sbin/ldconfig</command>.
If in doubt, refer to the manual pages of your system. If you later on get
</para>
a message like
<programlisting>
<para>
If in doubt, refer to the manual pages of your system. If you later on get
a message like
<programlisting>
psql: error in loading shared libraries
psql: error in loading shared libraries
libpq.so.2.1: cannot open shared object file: No such file or directory
libpq.so.2.1: cannot open shared object file: No such file or directory
</programlisting>
</programlisting>
then the above was necessary. Simply do this step then.
then the above was necessary. Simply do this step then.
</Para>
</para>
</Step>
</step>
<Step Performance="required">
<step performance="required">
<Para>
<para>
Create the database installation (the working data files).
Create the database installation (the working data files).
To do this you must log in to your
To do this you must log in to your
<ProductName>PostgreSQL</ProductName> superuser account. It will not
<productname>PostgreSQL</productname> superuser account. It will not
work as root.
work as root.
<ProgramListing>
<programlisting>
mkdir /usr/local/pgsql/data
> mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
> chown postgres /usr/local/pgsql/data
su - postgres
> su - postgres
/usr/local/pgsql/initdb -D /usr/local/pgsql/data
> /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
</ProgramListing>
</programlisting>
</Para>
</para>
<Para>
<para>
The <option>-D</option> option specifies the location where the data will be
The <option>-D</option> option specifies the location where the data will be
stored. You can use any path you want, it does not have to be under
stored. You can use any path you want, it does not have to be under
the installation directory. Just make sure that the superuser account
the installation directory. Just make sure that the superuser account
can write to the directory (or create it, if it doesn't already exist)
can write to the directory (or create it, if it doesn't already exist)
before starting <command>initdb</command>.
before starting <command>initdb</command>.
(If you have already been doing the installation up to now as the <productname>PostgreSQL</productname>
(If you have already been doing the installation up to now as the
superuser, you may have to log in as root temporarily to create the data
<productname>PostgreSQL</productname>
directory underneath a root-owned directory.)
superuser, you may have to log in as root temporarily to create the data
</Para>
directory underneath a root-owned directory.)
</Step>
</para>
</step>
<Step Performance="required">
<Para>
<step performance="required">
The previous step should have told you how to start up the database server.
<para>
Do so now. The command should look something like
The previous step should have told you how to start up the database server.
<programlisting>
Do so now. The command should look something like
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
<programlisting>
</programlisting>
> /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
This will start the server in the foreground. To make it detach to
</programlisting>
the background, you can use the <option>-S</option> option, but then you won't
This will start the server in the foreground. To make it detach to
see any log messages the server produces. A better way to put the server
the background, you can use the <option>-S</option> option, but then you won't
in the background is
see any log messages the server produces. A better way to put the server
<programlisting>
in the background is
nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data \
<programlisting>
> nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data \
</dev/null >>server.log 2>>1 &
</dev/null >>server.log 2>>1 &
</programlisting>
</programlisting>
</Para>
</para>
</Step>
</step>
<step performance="optional">
<para>
If you are upgrading from an existing installation, dump your data back in:
<programlisting>
> /usr/local/pgsql/bin/psql -d template1 -f db.out
</programlisting>
You also might want to copy over the old <filename>pg_hba.conf</filename>
file and any other files you might have had set up for authentication, such
as password files.
</para>
</step>
</procedure>
<Step Performance="optional">
<para>
<para>
This concludes the installation proper. To make your life more
If you are upgrading from an existing installation, dump your data back in:
productive and enjoyable
<programlisting>
you should look at the following optional steps and suggestions.
/usr/local/pgsql/bin/psql -d template1 -f db.out
</para>
</programlisting>
You also might want to copy over the old <filename>pg_hba.conf</filename>
file and any other files you might have had set up for authentication, such
as password files.
</Para>
</Step>
</Procedure>
<para>
This concludes the installation proper. To make your life more productive and enjoyable
you should look at the following optional steps and suggestions.
</para>
<itemizedlist>
<listitem>
<Para>
Life will be more convenient if you set up some environment variables. First of all
you probably want to include <filename>/usr/local/pgsql/bin</filename> (or equivalent)
into your <envar>PATH</envar>. To do this, add the following to your shell startup
file, such as <filename>~/.bash_profile</filename> (or <filename>/etc/profile</filename>,
if you want it to affect every user):
<programlisting>
PATH=$PATH:/usr/local/pgsql/bin
</programlisting>
</Para>
<Para>
Furthermore, if you set <envar>PGDATA</envar> in the environment of the PostgreSQL
superuser, you can omit the <option>-D</option> for <filename>postmaster</filename>
and <filename>initdb</filename>.
</Para>
</listitem>
<listitem>
<Para>
You probably want to install the <application>man</application> and
<acronym>HTML</acronym> documentation. Type
<ProgramListing>
cd /usr/src/pgsql/postgresql-7.0/doc
gmake install
</ProgramListing>
This will install files under <filename>/usr/local/pgsql/doc</filename>
and <filename>/usr/local/pgsql/man</filename>. To enable your system
to find the <application>man</application> documentation, you need to
add a line like the following to a shell startup file:
<ProgramListing>
MANPATH=$MANPATH:/usr/local/pgsql/man
</ProgramListing>
</para>
<para>
The documentation is also available in Postscript format. If you have
a Postscript printer, or have your machine already set up to accept
Postscript files using a print filter, then to print the User's Guide
simply type
<programlisting>
cd /usr/local/pgsql/doc
gunzip -c user.ps.tz | lpr
</programlisting>
Here is how you might do it if you have Ghostscript on your system and are
writing to a laserjet printer.
<programlisting>
gunzip -c user.ps.gz | gs -sDEVICE=laserjet -r300 -q -dNOPAUSE -sOutputFile=- | lpr
</programlisting>
Printer setups can vary wildly from system to system.
If in doubt, consult your manuals or your local expert.
</para>
<para>
The Adminstrator's Guide should probably be your first reading if you
are completely new to <productname>PostgreSQL</productname>, as it contains
information about how to set up database users and authentication.
</para>
</listitem>
<listitem>
<Para>
Usually, you will want to modify your computer so that it will automatically
start the database server whenever it boots.
This is not required; the <ProductName>PostgreSQL</ProductName> server can
be run successfully from non-privileged accounts without root intervention.
</para>
<para>
Different systems have different conventions for starting up daemons at boot time,
so you are advised to familiarize yourself with them.
Most systems have a file <filename>/etc/rc.local</filename> or
<filename>/etc/rc.d/rc.local</filename> which is almost certainly no bad place
to put such a command.
Whatever you do, postmaster must be run by the <ProductName>PostgreSQL</ProductName>
superuser (<literal>postgres</literal>) <emphasis>and not by root</emphasis> or
any other user. Therefore you probably always want to form your command lines
along the lines of <literal>su -c '...' postgres</literal>.
</para>
<para>
It might be advisable to keep a log of the server output. To start the server that way
try:
<ProgramListing>
nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1' postgres &
</ProgramListing>
</para>
<para>
Here are a few more operating system specific suggestions.
<itemizedlist>
<listitem>
<para>
Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris
2.5.1 to contain the following single line:
<programlisting>
su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
</programlisting>
</para>
</listitem>
<listitem>
<para>
In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
contain the following lines and make it chmod 755 and chown
root:bin.
<programlisting>
<itemizedlist>
<listitem>
<para>
Life will be more convenient if you set up some environment
variables. First of all
you probably want to include
<filename>/usr/local/pgsql/bin</filename> (or equivalent)
into your <envar>PATH</envar>. To do this, add the following to
your shell startup
file, such as <filename>~/.bash_profile</filename> (or
<filename>/etc/profile</filename>,
if you want it to affect every user):
<programlisting>
> PATH=$PATH:/usr/local/pgsql/bin
</programlisting>
</para>
<para>
Furthermore, if you set <envar>PGDATA</envar> in the environment
of the PostgreSQL
superuser, you can omit the <option>-D</option> for
<filename>postmaster</filename>
and <filename>initdb</filename>.
</para>
</listitem>
<listitem>
<para>
You probably want to install the <application>man</application> and
<acronym>HTML</acronym> documentation. Type
<programlisting>
> cd /usr/src/pgsql/postgresql-7.0/doc
> gmake install
</programlisting>
This will install files under <filename>/usr/local/pgsql/doc</filename>
and <filename>/usr/local/pgsql/man</filename>. To enable your system
to find the <application>man</application> documentation, you need to
add a line like the following to a shell startup file:
<programlisting>
> MANPATH=$MANPATH:/usr/local/pgsql/man
</programlisting>
</para>
<para>
The documentation is also available in Postscript format. If you have
a Postscript printer, or have your machine already set up to accept
Postscript files using a print filter, then to print the User's Guide
simply type
<programlisting>
> cd /usr/local/pgsql/doc
> gunzip -c user.ps.tz | lpr
</programlisting>
Here is how you might do it if you have Ghostscript on your system and are
writing to a laserjet printer.
<programlisting>
> gunzip -c user.ps.gz \
| gs -sDEVICE=laserjet -r300 -q -dNOPAUSE -sOutputFile=- \
| lpr
</programlisting>
Printer setups can vary wildly from system to system.
If in doubt, consult your manuals or your local expert.
</para>
<para>
The Adminstrator's Guide should probably be your first reading if you
are completely new to <productname>PostgreSQL</productname>, as it contains
information about how to set up database users and authentication.
</para>
</listitem>
<listitem>
<para>
Usually, you will want to modify your computer so that it will automatically
start the database server whenever it boots.
This is not required; the <productname>PostgreSQL</productname> server can
be run successfully from non-privileged accounts without root intervention.
</para>
<para>
Different systems have different conventions for starting up
daemons at boot time,
so you are advised to familiarize yourself with them.
Most systems have a file <filename>/etc/rc.local</filename> or
<filename>/etc/rc.d/rc.local</filename> which is almost
certainly no bad place
to put such a command.
Whatever you do, postmaster must be run by the
<productname>PostgreSQL</productname>
superuser (<literal>postgres</literal>) <emphasis>and not by
root</emphasis> or
any other user. Therefore you probably always want to form your command lines
along the lines of <literal>su -c '...' postgres</literal>.
</para>
<para>
It might be advisable to keep a log of the server output. To
start the server that way
try:
<programlisting>
> nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1' postgres &
</programlisting>
</para>
<para>
Here are a few more operating system specific suggestions.
<itemizedlist>
<listitem>
<para>
Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris
2.5.1 to contain the following single line:
<programlisting>
> su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
</programlisting>
</para>
</listitem>
<listitem>
<para>
In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
contain the following lines and make it chmod 755 and chown
root:bin.
<programlisting>
#!/bin/sh
#!/bin/sh
[ -x /usr/local/pgsql/bin/postmaster ] && {
[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
...
@@ -550,57 +583,58 @@ In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
...
@@ -550,57 +583,58 @@ In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
-S -o -F > /usr/local/pgsql/errlog' &
-S -o -F > /usr/local/pgsql/errlog' &
echo -n ' pgsql'
echo -n ' pgsql'
}
}
</programlisting>
</programlisting>
You may put the line breaks as shown above. The shell is smart
enough to keep parsing beyond end-of-line if there is an
expression unfinished. The exec saves one layer of shell under
the postmaster process so the parent is init.
</para>
</listitem>
<listitem>
<para>
In RedHat Linux add a file
<filename>/etc/rc.d/init.d/postgres.init</filename>
which is based on the example in <filename>contrib/linux/</filename>.
Then make a softlink to this file from
<filename>/etc/rc.d/rc5.d/S98postgres.init</filename>.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
Run the regression tests against the installed server (using the sequential
test method). If you didn't run the tests before installation, you should
definitely do it now.
For detailed instructions see <xref endterm="regress-title"
linkend="regress">.
</para>
</listitem>
</itemizedlist>
<para>
To start <quote>playing around</quote>, set up the paths as explained above
and start the server. To create a database, type
<programlisting>
> createdb testdb
</programlisting>
Then enter
<programlisting>
> psql testdb
</programlisting>
to connect to that database. At the prompt you can enter SQL commands
and start experimenting.
</para>
You may put the line breaks as shown above. The shell is smart
</sect1>
enough to keep parsing beyond end-of-line if there is an
</chapter>
expression unfinished. The exec saves one layer of shell under
the postmaster process so the parent is init.
</para>
</listitem>
<listitem>
<para>
In RedHat Linux add a file <filename>/etc/rc.d/init.d/postgres.init</filename>
which is based on the example in <filename>contrib/linux/</filename>.
Then make a softlink to this file from
<filename>/etc/rc.d/rc5.d/S98postgres.init</filename>.
</para>
</listitem>
</itemizedlist>
</Para>
</listitem>
<listitem>
<Para>
Run the regression tests against the installed server (using the sequential
test method). If you didn't run the tests before installation, you should
definitely do it now.
For detailed instructions see <xref linkend="regress" endterm="regress-title">.
</Para>
</listitem>
</itemizedlist>
<Para>
To start <quote>playing around</quote>, set up the paths as explained above
and start the server. To create a database, type
<ProgramListing>
createdb testdb
</ProgramListing>
Then enter
<ProgramListing>
psql testdb
</ProgramListing>
to connect to that database. At the prompt you can enter SQL commands
and start experimenting.
</Para>
</Sect1>
</Chapter>
<!-- Keep this comment at the end of the file
<!-- Keep this comment at the end of the file
Local variables:
Local variables:
...
...
doc/src/sgml/intro.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.1
0 2000/03/31 03:27:40
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.1
1 2000/04/07 13:30:58
thomas Exp $
-->
-->
<chapter id="intro">
<chapter id="intro">
...
@@ -16,7 +16,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.10 2000/03/31 03:27:40 thoma
...
@@ -16,7 +16,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.10 2000/03/31 03:27:40 thoma
<productname>Postgres release 4.2</productname></ulink>.
<productname>Postgres release 4.2</productname></ulink>.
The <productname>Postgres</productname> project,
The <productname>Postgres</productname> project,
led by Professor Michael Stonebraker, was sponsored by the
led by Professor Michael Stonebraker, was sponsored by the
Defense Advanced Research Projects Agency (<acronym>DARPA</acronym>), the
Defense Advanced Research Projects Agency
(<acronym>DARPA</acronym>), the
Army Research Office (<acronym>ARO</acronym>), the National Science
Army Research Office (<acronym>ARO</acronym>), the National Science
Foundation (<acronym>NSF</acronym>), and ESL, Inc.
Foundation (<acronym>NSF</acronym>), and ESL, Inc.
</para>
</para>
...
@@ -37,7 +38,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.10 2000/03/31 03:27:40 thoma
...
@@ -37,7 +38,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.10 2000/03/31 03:27:40 thoma
models in part because of its "Spartan simplicity".
models in part because of its "Spartan simplicity".
However, as mentioned, this simplicity often makes the
However, as mentioned, this simplicity often makes the
implementation of certain applications very difficult.
implementation of certain applications very difficult.
<productname>Postgres</productname> offers substantial
additional
<productname>Postgres</productname> offers substantial additional
power by incorporating the following four additional
power by incorporating the following four additional
basic concepts in such a way that users can easily
basic concepts in such a way that users can easily
extend the system:
extend the system:
...
@@ -62,13 +63,16 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.10 2000/03/31 03:27:40 thoma
...
@@ -62,13 +63,16 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.10 2000/03/31 03:27:40 thoma
</para>
</para>
<para>
<para>
These features put <productname>Postgres</productname> into the category of databases
These features put <productname>Postgres</productname> into the
referred to as <firstterm>object-relational</firstterm>. Note that this is distinct
category of databases referred to as
from those referred to as <firstterm>object-oriented</firstterm>, which in general
<firstterm>object-relational</firstterm>. Note that this is distinct
are not as well suited to supporting the traditional relational database languages.
from those referred to as <firstterm>object-oriented</firstterm>,
So, although <productname>Postgres</productname> has some object-oriented features,
which in general are not as well suited to supporting the
it is firmly in the relational database world. In fact, some commercial databases
traditional relational database languages.
have recently incorporated features pioneered by <productname>Postgres</productname>.
So, although <productname>Postgres</productname> has some
object-oriented features, it is firmly in the relational database
world. In fact, some commercial databases have recently
incorporated features pioneered by <productname>Postgres</productname>.
</para>
</para>
</sect1>
</sect1>
...
...
doc/src/sgml/legal.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/legal.sgml,v 1.
7 2000/03/31 03:27:40
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/legal.sgml,v 1.
8 2000/04/07 13:30:58
thomas Exp $
-->
-->
<sect1 id="copyright">
<sect1 id="copyright">
...
@@ -7,7 +7,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/legal.sgml,v 1.7 2000/03/31 03:27:40 thomas
...
@@ -7,7 +7,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/legal.sgml,v 1.7 2000/03/31 03:27:40 thomas
<para>
<para>
<productname>PostgreSQL</productname> is Copyright © 1996-2000
<productname>PostgreSQL</productname> is Copyright © 1996-2000
by
the
PostgreSQL Inc.
by PostgreSQL Inc.
and is distributed under the terms of the Berkeley license.
and is distributed under the terms of the Berkeley license.
</para>
</para>
...
@@ -35,14 +35,22 @@ $Header: /cvsroot/pgsql/doc/src/sgml/legal.sgml,v 1.7 2000/03/31 03:27:40 thomas
...
@@ -35,14 +35,22 @@ $Header: /cvsroot/pgsql/doc/src/sgml/legal.sgml,v 1.7 2000/03/31 03:27:40 thomas
maintainance, support, updates, enhancements, or modifications.
maintainance, support, updates, enhancements, or modifications.
</para>
</para>
<!--
How to keep track of all the trademarks? I'll try the strategy used at
www.qnx.com - thomas
<para>
<para>
<acronym>Unix</acronym> is a trademark of X/Open, Ltd. Sun4, SPARC, SunOS
<acronym>Unix</acronym> is a trademark of X/Open, Ltd. Sun4, SPARC, SunOS
and Solaris are trademarks of Sun Microsystems, Inc. DEC,
and Solaris are trademarks of Sun Microsystems, Inc. DEC,
DECstation, Alpha AXP and ULTRIX are trademarks of Digital
DECstation, Alpha AXP and ULTRIX are trademarks of
Compaq, formerly
Digital
Equipment Corp. PA-RISC and HP-UX are trademarks of
Equipment Corp. PA-RISC and HP-UX are trademarks of
Hewlett-Packard Co. OSF/1 is a trademark of the Open
Hewlett-Packard Co. OSF/1 is a trademark of the Open
Software Foundation.
Software Foundation.
</para>
</para>
-->
<para>
All trademarks are the property of their respective owners.
</para>
</sect1>
</sect1>
<!-- Keep this comment at the end of the file
<!-- Keep this comment at the end of the file
...
...
doc/src/sgml/notation.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.
8 2000/03/31 03:27:41
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.
9 2000/04/07 13:30:58
thomas Exp $
-->
-->
<sect1 id="terminology">
<sect1 id="terminology">
...
@@ -25,13 +25,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.8 2000/03/31 03:27:41 tho
...
@@ -25,13 +25,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.8 2000/03/31 03:27:41 tho
binaries and database files. As the database superuser, all
binaries and database files. As the database superuser, all
protection mechanisms may be bypassed and any data accessed
protection mechanisms may be bypassed and any data accessed
arbitrarily.
arbitrarily.
In addition, the <Productname>Postgres</Productname> superuser is allowed to execute
In addition, the <Productname>Postgres</Productname> superuser is
allowed to execute
some support programs which are generally not available to all users.
some support programs which are generally not available to all users.
Note that the <Productname>Postgres</Productname> superuser is
Note that the <Productname>Postgres</Productname> superuser is
<emphasis>not</emphasis>
<emphasis>not</emphasis>
the same as the Unix superuser (which will be referred to as <firstterm>root</firstterm>).
the same as the Unix superuser (which will be referred to as
The superuser should have a non-zero user identifier (<firstterm>UID</firstterm>)
<firstterm>root</firstterm>).
for security reasons.
The superuser should have a non-zero user identifier
(<firstterm>UID</firstterm>) for security reasons.
</para>
</para>
<para>
<para>
...
@@ -82,18 +84,21 @@ $Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.8 2000/03/31 03:27:41 tho
...
@@ -82,18 +84,21 @@ $Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.8 2000/03/31 03:27:41 tho
In a command synopsis, brackets
In a command synopsis, brackets
(<quote>[</quote> and <quote>]</quote>) indicate an optional phrase or keyword.
(<quote>[</quote> and <quote>]</quote>) indicate an optional phrase or keyword.
Anything in braces
Anything in braces
(<quote>{</quote> and <quote>}</quote>) and containing vertical bars (<quote>|</quote>)
(<quote>{</quote> and <quote>}</quote>) and containing vertical bars
(<quote>|</quote>)
indicates that you must choose one.
indicates that you must choose one.
</para>
</para>
<para>
<para>
In examples, parentheses (<quote>(</quote> and <quote>)</quote>) are used to group boolean
In examples, parentheses (<quote>(</quote> and <quote>)</quote>) are
used to group boolean
expressions. <quote>|</quote> is the boolean operator OR.
expressions. <quote>|</quote> is the boolean operator OR.
</para>
</para>
<para>
<para>
Examples will show commands executed from various accounts and programs.
Examples will show commands executed from various accounts and programs.
Commands executed from the root account will be preceeded with <quote>></quote>.
Commands executed from the root account will be preceeded with
<quote>></quote>.
Commands executed from the <Productname>Postgres</Productname>
Commands executed from the <Productname>Postgres</Productname>
superuser account will be preceeded with <quote>%</quote>, while commands
superuser account will be preceeded with <quote>%</quote>, while commands
executed from an unprivileged user's account will be preceeded with
executed from an unprivileged user's account will be preceeded with
...
@@ -104,8 +109,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.8 2000/03/31 03:27:41 tho
...
@@ -104,8 +109,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/notation.sgml,v 1.8 2000/03/31 03:27:41 tho
<note>
<note>
<para>
<para>
At the time of writing (<Productname>Postgres</Productname> v6.5) the notation for
At the time of writing (<Productname>Postgres</Productname> v7.0)
flagging commands is not universally consistant throughout the documentation set.
the notation for
flagging commands is not universally consistant throughout the
documentation set.
Please report problems to
Please report problems to
<ulink url="mailto:docs@postgresql.org">the Documentation Mailing List</ulink>.
<ulink url="mailto:docs@postgresql.org">the Documentation Mailing List</ulink>.
</para>
</para>
...
...
doc/src/sgml/ports.sgml
View file @
30e355fc
...
@@ -32,15 +32,15 @@
...
@@ -32,15 +32,15 @@
<row>
<row>
<entry>AIX 4.3.2</entry>
<entry>AIX 4.3.2</entry>
<entry>RS6000</entry>
<entry>RS6000</entry>
<entry>v
6.5
</entry>
<entry>v
7.0
</entry>
<entry>
1999-05-26
</entry>
<entry>
2000-04-05
</entry>
<entry>(<ulink url="mailto:Andreas.Zeugswetter@telecom.at">Andreas Zeugswetter</ulink>)</entry>
<entry>(<ulink url="mailto:Andreas.Zeugswetter@telecom.at">Andreas Zeugswetter</ulink>)</entry>
</row>
</row>
<row>
<row>
<entry>BSDI</entry>
<entry>BSDI
4.01
</entry>
<entry>x86</entry>
<entry>x86</entry>
<entry>v
6.5
</entry>
<entry>v
7.0
</entry>
<entry>
1999-05-25
</entry>
<entry>
2000-04-04
</entry>
<entry>(<ulink url="mailto:maillist@candle.pha.pa.us">Bruce Momjian</ulink></entry>
<entry>(<ulink url="mailto:maillist@candle.pha.pa.us">Bruce Momjian</ulink></entry>
</row>
</row>
<row>
<row>
...
@@ -60,12 +60,11 @@
...
@@ -60,12 +60,11 @@
(<ulink url="mailto:pjlobo@euitt.upm.es">Pedro J. Lobo</ulink>)</entry>
(<ulink url="mailto:pjlobo@euitt.upm.es">Pedro J. Lobo</ulink>)</entry>
</row>
</row>
<row>
<row>
<entry>FreeBSD
2.2.x-
4.0</entry>
<entry>FreeBSD 4.0</entry>
<entry>x86</entry>
<entry>x86</entry>
<entry>v6.5</entry>
<entry>v7.0</entry>
<entry>1999-05-25</entry>
<entry>2000-04-04</entry>
<entry>(<ulink url="mailto:t-ishii@sra.co.jp">Tatsuo Ishii</ulink>,
<entry>(<ulink url="mailto:scrappy@hub.org">Marc Fournier</ulink>)</entry>
<ulink url="mailto:scrappy@hub.org">Marc Fournier</ulink>)</entry>
</row>
</row>
<row>
<row>
<entry>HPUX</entry>
<entry>HPUX</entry>
...
@@ -136,17 +135,17 @@
...
@@ -136,17 +135,17 @@
(<ulink url="mailto:t-ishii@sra.co.jp">Tatsuo Ishii</ulink>)</entry>
(<ulink url="mailto:t-ishii@sra.co.jp">Tatsuo Ishii</ulink>)</entry>
</row>
</row>
<row>
<row>
<entry>Linux 2.
0.x
</entry>
<entry>Linux 2.
2.5
</entry>
<entry>Sparc</entry>
<entry>Sparc</entry>
<entry>v
6.4
</entry>
<entry>v
7.0
</entry>
<entry>
1998-10-25
</entry>
<entry>
2000-04-02
</entry>
<entry>(<ulink url="mailto:szybist@boxhill.com">Tom Szybist</ulink>)</entry>
<entry>(<ulink url="mailto:szybist@boxhill.com">Tom Szybist</ulink>)</entry>
</row>
</row>
<row>
<row>
<entry>LinuxPPC R4
2.2.1/libc5
</entry>
<entry>LinuxPPC R4</entry>
<entry>PPC603e</entry>
<entry>PPC603e</entry>
<entry>v7.0</entry>
<entry>v7.0</entry>
<entry>2000-0
3-26
</entry>
<entry>2000-0
4-04
</entry>
<entry>Powerbook 2400c
<entry>Powerbook 2400c
(<ulink url="mailto:t-ishii@sra.co.jp">Tatsuo Ishii</ulink>)</entry>
(<ulink url="mailto:t-ishii@sra.co.jp">Tatsuo Ishii</ulink>)</entry>
</row>
</row>
...
@@ -250,20 +249,20 @@
...
@@ -250,20 +249,20 @@
(<ulink url="mailto:ridderbusch.pad@sni.de">Frank Ridderbusch</ulink>)</entry>
(<ulink url="mailto:ridderbusch.pad@sni.de">Frank Ridderbusch</ulink>)</entry>
</row>
</row>
<row>
<row>
<entry>Windows</entry>
<entry>Windows
/Win32
</entry>
<entry>x86</entry>
<entry>x86</entry>
<entry>v
6.4
</entry>
<entry>v
7.0
</entry>
<entry>
1999-01-06
</entry>
<entry>
2000-04-02
</entry>
<entry>Client-side libraries or ODBC/JDBC. No server
yet
.
<entry>Client-side libraries or ODBC/JDBC. No server
-side
.
(<ulink url="mha@sollentuna.net">Magnus Hagander</ulink></entry>
(<ulink url="mha@sollentuna.net">Magnus Hagander</ulink></entry>
</row>
</row>
<row>
<row>
<entry>Win
dows NT
</entry>
<entry>Win
NT/Cygwin
</entry>
<entry>x86</entry>
<entry>x86</entry>
<entry>v
6.5
</entry>
<entry>v
7.0
</entry>
<entry>
1999-05-26
</entry>
<entry>
2000-03-30
</entry>
<entry>Working with the Cygwin library.
<entry>Working with the Cygwin library.
(<ulink url="mailto:
Dan.Horak@email
.cz">Daniel Horak</ulink>) </entry>
(<ulink url="mailto:
horak@sit.plzen-city
.cz">Daniel Horak</ulink>) </entry>
</row>
</row>
</tbody>
</tbody>
</tgroup>
</tgroup>
...
@@ -273,8 +272,9 @@
...
@@ -273,8 +272,9 @@
<note>
<note>
<para>
<para>
For <productname>Windows NT</productname>,
For <productname>Windows NT</productname>,
the server-side port of <productname>Postgres</productname> has recently been
the server-side port of <productname>Postgres</productname> uses
accomplished. The Cygnus library is required to compile it.
the RedHat/Cygnus <productname>Cygwin</productname> library and
toolset.
</para>
</para>
</note>
</note>
</sect1>
</sect1>
...
@@ -289,7 +289,8 @@
...
@@ -289,7 +289,8 @@
</para>
</para>
<para>
<para>
At the time of publication, the following platforms have been tested:
At the time of publication, the following platforms have not been
tested for v7.0:
<table tocentry="1">
<table tocentry="1">
<title>Obsolete Platforms</title>
<title>Obsolete Platforms</title>
...
...
doc/src/sgml/query.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.
9 2000/03/31 03:27:41
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.
10 2000/04/07 13:30:58
thomas Exp $
-->
-->
<chapter id="query">
<chapter id="query">
...
@@ -8,20 +8,21 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.9 2000/03/31 03:27:41 thomas
...
@@ -8,20 +8,21 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.9 2000/03/31 03:27:41 thomas
<para>
<para>
The <productname>Postgres</productname> query language is a variant of
The <productname>Postgres</productname> query language is a variant of
the <acronym>SQL3</acronym> draft next-generation standard. It
the <acronym>SQL3</acronym> draft next-generation standard. It
has many extensions such as an extensible type system,
has many extensions to <acronym>SQL92</acronym> such as an
extensible type system,
inheritance, functions and production rules. These are
inheritance, functions and production rules. These are
features carried over from the original <productname>Postgres</productname> query
features carried over from the original
language, <productname>PostQuel</productname>. This section provides an overview
<productname>Postgres</productname> query
language, <productname>PostQuel</productname>.
This section provides an overview
of how to use <productname>Postgres</productname>
of how to use <productname>Postgres</productname>
<acronym>SQL</acronym> to perform simple operations.
<acronym>SQL</acronym> to perform simple operations.
This manual is only intended to give you an idea of our
This manual is only intended to give you an idea of our
flavor of <acronym>SQL</acronym> and is in no way a complete tutorial on
flavor of <acronym>SQL</acronym> and is in no way a complete tutorial on
<acronym>SQL</acronym>. Numerous books have been written on
<acronym>SQL</acronym>. Numerous books have been written on
<acronym>SQL</acronym>, including
<acronym>SQL92</acronym>, including
<!--
<xref linkend="MELT93" endterm="MELT93-title"> and
<XRef LinkEnd="MELT93"> and <XRef LinkEnd="DATE97">.
<xref linkend="DATE97" endterm="DATE97-title">.
-->
[MELT93] and [DATE97].
You should be aware that some language features
You should be aware that some language features
are extensions to the <acronym>ANSI</acronym> standard.
are extensions to the <acronym>ANSI</acronym> standard.
</para>
</para>
...
@@ -111,22 +112,26 @@ CREATE TABLE weather (
...
@@ -111,22 +112,26 @@ CREATE TABLE weather (
</para>
</para>
<para>
<para>
Note that both keywords and identifiers are case-insensitive; identifiers can become
Note that both keywords and identifiers are case-insensitive;
case-sensitive by surrounding them with double-quotes as allowed
identifiers can preserve case by surrounding them with
double-quotes as allowed
by <acronym>SQL92</acronym>.
by <acronym>SQL92</acronym>.
<productname>Postgres</productname> <acronym>SQL</acronym> supports the usual
<productname>Postgres</productname> <acronym>SQL</acronym>
supports the usual
<acronym>SQL</acronym> types <type>int</type>,
<acronym>SQL</acronym> types <type>int</type>,
<type>float</type>, <type>real</type>, <type>smallint</type>,
<type>float</type>, <type>real</type>, <type>smallint</type>,
<type>char(N)</type>,
<type>char(N)</type>,
<type>varchar(N)</type>, <type>date</type>, <type>time</type>,
<type>varchar(N)</type>, <type>date</type>, <type>time</type>,
and <type>timestamp</type>, as well as other types of general utility and
and <type>timestamp</type>, as well as other types of general utility and
a rich set of geometric types. As we will
a rich set of geometric types. As we will
see later, <productname>Postgres</productname> can be customized with an
see later, <productname>Postgres</productname> can be customized
with an
arbitrary number of
arbitrary number of
user-defined data types. Consequently, type names are
user-defined data types. Consequently, type names are
not syntactical keywords, except where required to support special
not syntactical keywords, except where required to support special
cases in the <acronym>SQL92</acronym> standard.
cases in the <acronym>SQL92</acronym> standard.
So far, the <productname>Postgres</productname> <command>CREATE</command> command
So far, the <productname>Postgres</productname>
<command>CREATE</command> command
looks exactly like
looks exactly like
the command used to create a table in a traditional
the command used to create a table in a traditional
relational system. However, we will presently see that
relational system. However, we will presently see that
...
@@ -139,7 +144,7 @@ CREATE TABLE weather (
...
@@ -139,7 +144,7 @@ CREATE TABLE weather (
<title>Populating a Class with Instances</title>
<title>Populating a Class with Instances</title>
<para>
<para>
The <command>
insert
</command> statement is used to populate a class with
The <command>
INSERT
</command> statement is used to populate a class with
instances:
instances:
<programlisting>
<programlisting>
...
@@ -149,9 +154,10 @@ INSERT INTO weather
...
@@ -149,9 +154,10 @@ INSERT INTO weather
</para>
</para>
<para>
<para>
You can also use the <command>
copy
</command> command to perform load large
You can also use the <command>
COPY
</command> command to perform load large
amounts of data from flat (<acronym>ASCII</acronym>) files.
amounts of data from flat (<acronym>ASCII</acronym>) files.
This is usually faster because the data is read (or written) as a single atomic
This is usually faster because the data is read (or written) as a
single atomic
transaction directly to or from the target table. An example would be:
transaction directly to or from the target table. An example would be:
<programlisting>
<programlisting>
...
@@ -159,7 +165,8 @@ COPY weather FROM '/home/user/weather.txt'
...
@@ -159,7 +165,8 @@ COPY weather FROM '/home/user/weather.txt'
USING DELIMITERS '|';
USING DELIMITERS '|';
</programlisting>
</programlisting>
where the path name for the source file must be available to the backend server
where the path name for the source file must be available to the
backend server
machine, not the client, since the backend server reads the file directly.
machine, not the client, since the backend server reads the file directly.
</para>
</para>
</sect1>
</sect1>
...
@@ -170,7 +177,7 @@ COPY weather FROM '/home/user/weather.txt'
...
@@ -170,7 +177,7 @@ COPY weather FROM '/home/user/weather.txt'
<para>
<para>
The weather class can be queried with normal relational
The weather class can be queried with normal relational
selection and projection queries. A <acronym>SQL</acronym>
selection and projection queries. A <acronym>SQL</acronym>
<command>
select
</command>
<command>
SELECT
</command>
statement is used to do this. The statement is divided into
statement is used to do this. The statement is divided into
a target list (the part that lists the attributes to be
a target list (the part that lists the attributes to be
returned) and a qualification (the part that specifies
returned) and a qualification (the part that specifies
...
@@ -192,7 +199,8 @@ SELECT * FROM weather;
...
@@ -192,7 +199,8 @@ SELECT * FROM weather;
|Hayward | 37 | 54 | | 11-29-1994 |
|Hayward | 37 | 54 | | 11-29-1994 |
+--------------+---------+---------+------+------------+
+--------------+---------+---------+------+------------+
</programlisting>
</programlisting>
You may specify any arbitrary expressions in the target list. For example, you can do:
You may specify any arbitrary expressions in the target list. For
example, you can do:
<programlisting>
<programlisting>
SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;
SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;
</programlisting>
</programlisting>
...
@@ -200,7 +208,8 @@ SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;
...
@@ -200,7 +208,8 @@ SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;
<para>
<para>
Arbitrary Boolean operators
Arbitrary Boolean operators
(<command>and</command>, <command>or</command> and <command>not</command>) are
(<command>AND</command>, <command>OR</command> and
<command>NOT</command>) are
allowed in the qualification of any query. For example,
allowed in the qualification of any query. For example,
<programlisting>
<programlisting>
...
@@ -235,16 +244,16 @@ SELECT DISTINCT city
...
@@ -235,16 +244,16 @@ SELECT DISTINCT city
<title>Redirecting SELECT Queries</title>
<title>Redirecting SELECT Queries</title>
<para>
<para>
Any
select
query can be redirected to a new class
Any
<command>SELECT</command>
query can be redirected to a new class
<programlisting>
<programlisting>
SELECT * INTO TABLE temp FROM weather;
SELECT * INTO TABLE temp FROM weather;
</programlisting>
</programlisting>
</para>
</para>
<para>
<para>
This forms an implicit <command>
create
</command> command, creating a new
This forms an implicit <command>
CREATE
</command> command, creating a new
class temp with the attribute names and types specified
class temp with the attribute names and types specified
in the target list of the <command>
select into
</command> command. We can
in the target list of the <command>
SELECT INTO
</command> command. We can
then, of course, perform any operations on the resulting
then, of course, perform any operations on the resulting
class that we can perform on other classes.
class that we can perform on other classes.
</para>
</para>
...
@@ -269,7 +278,8 @@ SELECT * INTO TABLE temp FROM weather;
...
@@ -269,7 +278,8 @@ SELECT * INTO TABLE temp FROM weather;
<note>
<note>
<para>
<para>
This is only a conceptual model. The actual join may
This is only a conceptual model. The actual join may
be performed in a more efficient manner, but this is invisible to the user.
be performed in a more efficient manner, but this is invisible
to the user.
</para>
</para>
</note>
</note>
...
@@ -307,16 +317,18 @@ SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high,
...
@@ -307,16 +317,18 @@ SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high,
sometimes recomputes the same target list several times;
sometimes recomputes the same target list several times;
this frequently happens when Boolean expressions are connected
this frequently happens when Boolean expressions are connected
with an "or". To remove such duplicates, you must use
with an "or". To remove such duplicates, you must use
the <command>
select distinct
</command> statement.
the <command>
SELECT DISTINCT
</command> statement.
</para>
</para>
</note>
</note>
</para>
</para>
<para>
<para>
In this case, both W1 and W2 are surrogates for an
In this case, both <literal>W1</literal> and
<literal>W2</literal> are surrogates for an
instance of the class weather, and both range over all
instance of the class weather, and both range over all
instances of the class. (In the terminology of most
instances of the class. (In the terminology of most
database systems, W1 and W2 are known as <firstterm>range variables</firstterm>.)
database systems, <literal>W1</literal> and <literal>W2</literal>
are known as <firstterm>range variables</firstterm>.)
A query can contain an arbitrary number of
A query can contain an arbitrary number of
class names and surrogates.
class names and surrogates.
</para>
</para>
...
@@ -326,7 +338,8 @@ SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high,
...
@@ -326,7 +338,8 @@ SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high,
<title>Updates</title>
<title>Updates</title>
<para>
<para>
You can update existing instances using the update command.
You can update existing instances using the
<command>UPDATE</command> command.
Suppose you discover the temperature readings are
Suppose you discover the temperature readings are
all off by 2 degrees as of Nov 28, you may update the
all off by 2 degrees as of Nov 28, you may update the
data as follow:
data as follow:
...
@@ -343,7 +356,7 @@ UPDATE weather
...
@@ -343,7 +356,7 @@ UPDATE weather
<title>Deletions</title>
<title>Deletions</title>
<para>
<para>
Deletions are performed using the <command>
delete
</command> command:
Deletions are performed using the <command>
DELETE
</command> command:
<programlisting>
<programlisting>
DELETE FROM weather WHERE city = 'Hayward';
DELETE FROM weather WHERE city = 'Hayward';
</programlisting>
</programlisting>
...
@@ -354,7 +367,7 @@ DELETE FROM weather WHERE city = 'Hayward';
...
@@ -354,7 +367,7 @@ DELETE FROM weather WHERE city = 'Hayward';
DELETE FROM classname;
DELETE FROM classname;
</programlisting>
</programlisting>
Without a qualification, <command>
delete
</command> will simply
Without a qualification, <command>
DELETE
</command> will simply
remove all instances of the given class, leaving it
remove all instances of the given class, leaving it
empty. The system will not request confirmation before
empty. The system will not request confirmation before
doing this.
doing this.
...
@@ -365,7 +378,7 @@ DELETE FROM classname;
...
@@ -365,7 +378,7 @@ DELETE FROM classname;
<title>Using Aggregate Functions</title>
<title>Using Aggregate Functions</title>
<para>
<para>
Like most other
query language
s,
Like most other
relational database product
s,
<productname>PostgreSQL</productname> supports
<productname>PostgreSQL</productname> supports
aggregate functions.
aggregate functions.
An aggregate function computes a single result from multiple input rows.
An aggregate function computes a single result from multiple input rows.
...
@@ -377,20 +390,20 @@ DELETE FROM classname;
...
@@ -377,20 +390,20 @@ DELETE FROM classname;
<para>
<para>
It is important to understand the interaction between aggregates and
It is important to understand the interaction between aggregates and
SQL's <command>
where</command> and <command>having
</command> clauses.
SQL's <command>
WHERE</command> and <command>HAVING
</command> clauses.
The fundamental difference between <command>
where
</command> and
The fundamental difference between <command>
WHERE
</command> and
<command>
having</command> is this: <command>where
</command> selects
<command>
HAVING</command> is this: <command>WHERE
</command> selects
input rows before groups and aggregates are computed (thus, it controls
input rows before groups and aggregates are computed (thus, it controls
which rows go into the aggregate computation), whereas
which rows go into the aggregate computation), whereas
<command>
having
</command> selects group rows after groups and
<command>
HAVING
</command> selects group rows after groups and
aggregates are computed. Thus, the
aggregates are computed. Thus, the
<command>
where
</command> clause may not contain aggregate functions;
<command>
WHERE
</command> clause may not contain aggregate functions;
it makes no sense to try to use an aggregate to determine which rows
it makes no sense to try to use an aggregate to determine which rows
will be inputs to the aggregates. On the other hand,
will be inputs to the aggregates. On the other hand,
<command>
having
</command> clauses always contain aggregate functions.
<command>
HAVING
</command> clauses always contain aggregate functions.
(Strictly speaking, you are allowed to write a <command>
having
</command>
(Strictly speaking, you are allowed to write a <command>
HAVING
</command>
clause that doesn't use aggregates, but it's wasteful; the same condition
clause that doesn't use aggregates, but it's wasteful; the same condition
could be used more efficiently at the <command>
where
</command> stage.)
could be used more efficiently at the <command>
WHERE
</command> stage.)
</para>
</para>
<para>
<para>
...
@@ -408,13 +421,17 @@ SELECT max(temp_lo) FROM weather;
...
@@ -408,13 +421,17 @@ SELECT max(temp_lo) FROM weather;
SELECT city FROM weather WHERE temp_lo = max(temp_lo);
SELECT city FROM weather WHERE temp_lo = max(temp_lo);
</programlisting>
</programlisting>
but this will not work since the aggregate max() can't be used in
but this will not work since the aggregate
<command>where</command>. However, as is often the case the query can be
<function>max</function> can't be used in
<command>WHERE</command>. However, as is often the case the query can be
restated to accomplish the intended result; here by using a
restated to accomplish the intended result; here by using a
<firstterm>subselect</firstterm>:
<firstterm>subselect</firstterm>:
<programlisting>
<programlisting>
SELECT city FROM weather WHERE temp_lo = (SELECT max(temp_lo) FROM weather);
SELECT city FROM weather
WHERE temp_lo = (SELECT max(temp_lo) FROM weather);
</programlisting>
</programlisting>
This is OK because the sub-select is an independent computation that
This is OK because the sub-select is an independent computation that
computes its own aggregate separately from what's happening in the outer
computes its own aggregate separately from what's happening in the outer
select.
select.
...
@@ -422,24 +439,29 @@ SELECT city FROM weather WHERE temp_lo = (SELECT max(temp_lo) FROM weather);
...
@@ -422,24 +439,29 @@ SELECT city FROM weather WHERE temp_lo = (SELECT max(temp_lo) FROM weather);
<para>
<para>
Aggregates are also very useful in combination with
Aggregates are also very useful in combination with
<
firstterm>group by</firstterm
> clauses. For example, we can get the
<
command>GROUP BY</command
> clauses. For example, we can get the
maximum low temperature observed in each city with
maximum low temperature observed in each city with
<programlisting>
<programlisting>
SELECT city, max(temp_lo)
SELECT city, max(temp_lo)
FROM weather
FROM weather
GROUP BY city;
GROUP BY city;
</programlisting>
</programlisting>
which gives us one output row per city. We can filter these grouped
which gives us one output row per city. We can filter these grouped
rows using <command>having</command>:
rows using <command>HAVING</command>:
<programlisting>
<programlisting>
SELECT city, max(temp_lo)
SELECT city, max(temp_lo)
FROM weather
FROM weather
GROUP BY city
GROUP BY city
HAVING min(temp_lo) < 0;
HAVING min(temp_lo) < 0;
</programlisting>
</programlisting>
which gives us the same results for only the cities that have some
which gives us the same results for only the cities that have some
below-zero readings. Finally, if we only care about cities whose
below-zero readings. Finally, if we only care about cities whose
names begin with 'P', we might do
names begin with "<literal>P</literal>", we might do
<programlisting>
<programlisting>
SELECT city, max(temp_lo)
SELECT city, max(temp_lo)
FROM weather
FROM weather
...
@@ -447,11 +469,12 @@ SELECT city, max(temp_lo)
...
@@ -447,11 +469,12 @@ SELECT city, max(temp_lo)
GROUP BY city
GROUP BY city
HAVING min(temp_lo) < 0;
HAVING min(temp_lo) < 0;
</programlisting>
</programlisting>
Note that we can apply the city-name restriction in
Note that we can apply the city-name restriction in
<command>
where
</command>, since it needs no aggregate. This is
<command>
WHERE
</command>, since it needs no aggregate. This is
more efficient than adding the restriction to <command>
having
</command>,
more efficient than adding the restriction to <command>
HAVING
</command>,
because we avoid doing the grouping and aggregate calculations
because we avoid doing the grouping and aggregate calculations
for all rows that fail the <command>
where
</command> check.
for all rows that fail the <command>
WHERE
</command> check.
</para>
</para>
</sect1>
</sect1>
</chapter>
</chapter>
...
...
doc/src/sgml/sql.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.
7 2000/03/31 03:27:41
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.
8 2000/04/07 13:30:58
thomas Exp $
-->
-->
<chapter id="sql">
<chapter id="sql">
...
@@ -7,18 +7,28 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -7,18 +7,28 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
<abstract>
<abstract>
<para>
<para>
This chapter originally appeared as a part of
This chapter introduces the mathematical concepts behind
relational databases. It is not required reading, so if you bog
down or want to get straight to some simple examples feel free to
jump ahead to the next chapter and come back when you have more
time and patience. This stuff is supposed to be fun!
</para>
<para>
This material originally appeared as a part of
Stefan Simkovics' Master's Thesis
Stefan Simkovics' Master's Thesis
(<xref linkend="SIM98" endterm="SIM98">).
(<xref linkend="SIM98" endterm="SIM98">).
</para>
</para>
</abstract>
</abstract>
<para>
<para>
<acronym>SQL</acronym> has become the most popular relational query language.
<acronym>SQL</acronym> has become the most popular relational query
language.
The name <quote><acronym>SQL</acronym></quote> is an abbreviation for
The name <quote><acronym>SQL</acronym></quote> is an abbreviation for
<firstterm>Structured Query Language</firstterm>.
<firstterm>Structured Query Language</firstterm>.
In 1974 Donald Chamberlin and others defined the
In 1974 Donald Chamberlin and others defined the
language SEQUEL (<firstterm>Structured English Query Language</firstterm>) at IBM
language SEQUEL (<firstterm>Structured English Query
Language</firstterm>) at IBM
Research. This language was first implemented in an IBM
Research. This language was first implemented in an IBM
prototype called SEQUEL-XRM in 1974-75. In 1976-77 a revised version
prototype called SEQUEL-XRM in 1974-75. In 1976-77 a revised version
of SEQUEL called SEQUEL/2 was defined and the name was changed to
of SEQUEL called SEQUEL/2 was defined and the name was changed to
...
@@ -28,13 +38,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -28,13 +38,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
<para>
<para>
A new prototype called System R was developed by IBM in 1977. System R
A new prototype called System R was developed by IBM in 1977. System R
implemented a large subset of SEQUEL/2 (now <acronym>SQL</acronym>) and a number of
implemented a large subset of SEQUEL/2 (now <acronym>SQL</acronym>)
and a number of
changes were made to <acronym>SQL</acronym> during the project.
changes were made to <acronym>SQL</acronym> during the project.
System R was installed in
System R was installed in
a number of user sites, both internal IBM sites and also some selected
a number of user sites, both internal IBM sites and also some selected
customer sites. Thanks to the success and acceptance of System R at
customer sites. Thanks to the success and acceptance of System R at
those user sites IBM started to develop commercial products that
those user sites IBM started to develop commercial products that
implemented the <acronym>SQL</acronym> language based on the System R technology.
implemented the <acronym>SQL</acronym> language based on the System
R technology.
</para>
</para>
<para>
<para>
...
@@ -48,16 +60,20 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -48,16 +60,20 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
</para>
</para>
<para>
<para>
<acronym>SQL</acronym> is also an official standard now. In 1982 the American National
<acronym>SQL</acronym> is also an official standard now. In 1982
Standards Institute (<acronym>ANSI</acronym>) chartered its Database Committee X3H2 to
the American National
Standards Institute (<acronym>ANSI</acronym>) chartered its
Database Committee X3H2 to
develop a proposal for a standard relational language. This proposal
develop a proposal for a standard relational language. This proposal
was ratified in 1986 and consisted essentially of the IBM dialect of
was ratified in 1986 and consisted essentially of the IBM dialect of
<acronym>SQL</acronym>. In 1987 this <acronym>ANSI</acronym>
<acronym>SQL</acronym>. In 1987 this <acronym>ANSI</acronym>
standard was also accepted as an international
standard was also accepted as an international
standard by the International Organization for Standardization
standard by the International Organization for Standardization
(<acronym>ISO</acronym>).
(<acronym>ISO</acronym>).
This original standard version of <acronym>SQL</acronym> is often referred to,
This original standard version of <acronym>SQL</acronym> is often
informally, as "<abbrev>SQL/86</abbrev>". In 1989 the original standard was extended
referred to,
informally, as "<abbrev>SQL/86</abbrev>". In 1989 the original
standard was extended
and this new standard is often, again informally, referred to as
and this new standard is often, again informally, referred to as
"<abbrev>SQL/89</abbrev>". Also in 1989, a related standard called
"<abbrev>SQL/89</abbrev>". Also in 1989, a related standard called
<firstterm>Database Language Embedded <acronym>SQL</acronym></firstterm>
<firstterm>Database Language Embedded <acronym>SQL</acronym></firstterm>
...
@@ -73,12 +89,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -73,12 +89,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
ratified standard - "International Standard ISO/IEC 9075:1992,
ratified standard - "International Standard ISO/IEC 9075:1992,
Database Language <acronym>SQL</acronym>" - in late 1992.
Database Language <acronym>SQL</acronym>" - in late 1992.
<acronym>SQL/92</acronym> is the version
<acronym>SQL/92</acronym> is the version
normally meant when people refer to "the <acronym>SQL</acronym> standard". A detailed
normally meant when people refer to "the <acronym>SQL</acronym>
standard". A detailed
description of <acronym>SQL/92</acronym> is given in
description of <acronym>SQL/92</acronym> is given in
<xref linkend="DATE97" endterm="DATE97">. At the time of
<xref linkend="DATE97" endterm="DATE97">. At the time of
writing this document a new standard informally referred to
writing this document a new standard informally referred to
as <firstterm><acronym>SQL3</acronym></firstterm>
as <firstterm><acronym>SQL3</acronym></firstterm>
is under development. It is planned to make <acronym>SQL</acronym> a Turing-complete
is under development. It is planned to make <acronym>SQL</acronym>
a Turing-complete
language, i.e. all computable queries (e.g. recursive queries) will be
language, i.e. all computable queries (e.g. recursive queries) will be
possible. This is a very complex task and therefore the completion of
possible. This is a very complex task and therefore the completion of
the new standard can not be expected before 1999.
the new standard can not be expected before 1999.
...
@@ -100,8 +118,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -100,8 +118,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
</para>
</para>
<para>
<para>
A <firstterm>relational database</firstterm> is a database that is perceived by its
A <firstterm>relational database</firstterm> is a database that is
users as a <firstterm>collection of tables</firstterm> (and nothing else but tables).
perceived by its
users as a <firstterm>collection of tables</firstterm> (and
nothing else but tables).
A table consists of rows and columns where each row represents a
A table consists of rows and columns where each row represents a
record and each column represents an attribute of the records
record and each column represents an attribute of the records
contained in the table.
contained in the table.
...
@@ -154,13 +174,16 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -154,13 +174,16 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
</para>
</para>
<para>
<para>
The tables PART and SUPPLIER may be regarded as <firstterm>entities</firstterm> and
The tables PART and SUPPLIER may be regarded as
SELLS may be regarded as a <firstterm>relationship</firstterm> between a particular
<firstterm>entities</firstterm> and
SELLS may be regarded as a <firstterm>relationship</firstterm>
between a particular
part and a particular supplier.
part and a particular supplier.
</para>
</para>
<para>
<para>
As we will see later, <acronym>SQL</acronym> operates on tables like the ones just
As we will see later, <acronym>SQL</acronym> operates on tables
like the ones just
defined but before that we will study the theory of the relational
defined but before that we will study the theory of the relational
model.
model.
</para>
</para>
...
@@ -171,7 +194,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -171,7 +194,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
<para>
<para>
The mathematical concept underlying the relational model is the
The mathematical concept underlying the relational model is the
set-theoretic <firstterm>relation</firstterm> which is a subset of the Cartesian
set-theoretic <firstterm>relation</firstterm> which is a subset of
the Cartesian
product of a list of domains. This set-theoretic relation gives
product of a list of domains. This set-theoretic relation gives
the model its name (do not confuse it with the relationship from the
the model its name (do not confuse it with the relationship from the
<firstterm>Entity-Relationship model</firstterm>).
<firstterm>Entity-Relationship model</firstterm>).
...
@@ -184,7 +208,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
...
@@ -184,7 +208,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.7 2000/03/31 03:27:41 thomas E
<para>
<para>
<!--
<!--
\begin{definition}
\begin{definition}
The <firstterm>Cartesian product</firstterm> of domains $D_{1}, D_{2},\ldots, D_{k}$ written
The <firstterm>Cartesian product</firstterm> of domains $D_{1},
D_{2},\ldots, D_{k}$ written
\mbox{$D_{1} \times D_{2} \times \ldots \times D_{k}$} is the set of
\mbox{$D_{1} \times D_{2} \times \ldots \times D_{k}$} is the set of
all $k$-tuples $(v_{1},v_{2},\ldots,v_{k})$ such that \mbox{$v_{1} \in
all $k$-tuples $(v_{1},v_{2},\ldots,v_{k})$ such that \mbox{$v_{1} \in
D_{1}, v_{2} \in D_{2}, \ldots, v_{k} \in D_{k}$}.
D_{1}, v_{2} \in D_{2}, \ldots, v_{k} \in D_{k}$}.
...
@@ -304,8 +329,10 @@ attributes are taken from. We often write a relation scheme as
...
@@ -304,8 +329,10 @@ attributes are taken from. We often write a relation scheme as
<note>
<note>
<para>
<para>
A <firstterm>relation scheme</firstterm> is just a kind of template
A <firstterm>relation scheme</firstterm> is just a kind of template
whereas a <firstterm>relation</firstterm> is an instance of a <firstterm>relation
whereas a <firstterm>relation</firstterm> is an instance of a
scheme</firstterm>. The relation consists of tuples (and can therefore be
<firstterm>relation
scheme</firstterm>. The relation consists of tuples (and can
therefore be
viewed as a table); not so the relation scheme.
viewed as a table); not so the relation scheme.
</para>
</para>
</note>
</note>
...
@@ -332,8 +359,10 @@ attributes are taken from. We often write a relation scheme as
...
@@ -332,8 +359,10 @@ attributes are taken from. We often write a relation scheme as
<type>VARCHAR(20)</type> (this is the <acronym>SQL</acronym> type
<type>VARCHAR(20)</type> (this is the <acronym>SQL</acronym> type
for character strings of length <= 20),
for character strings of length <= 20),
the type of <classname>SNO</classname> will be
the type of <classname>SNO</classname> will be
<type>INTEGER</type>. With the assignment of a data type we also have selected
<type>INTEGER</type>. With the assignment of a data type we also
a domain for an attribute. The domain of <classname>SNAME</classname> is the set of all
have selected
a domain for an attribute. The domain of
<classname>SNAME</classname> is the set of all
character strings of length <= 20,
character strings of length <= 20,
the domain of <classname>SNO</classname> is the set of
the domain of <classname>SNO</classname> is the set of
all integer numbers.
all integer numbers.
...
@@ -345,7 +374,8 @@ attributes are taken from. We often write a relation scheme as
...
@@ -345,7 +374,8 @@ attributes are taken from. We often write a relation scheme as
<title id="operations">Operations in the Relational Data Model</title>
<title id="operations">Operations in the Relational Data Model</title>
<para>
<para>
In the previous section (<xref linkend="formal-notion" endterm="formal-notion">)
In the previous section
(<xref linkend="formal-notion" endterm="formal-notion">)
we defined the mathematical notion of
we defined the mathematical notion of
the relational model. Now we know how the data can be stored using a
the relational model. Now we know how the data can be stored using a
relational data model but we do not know what to do with all these
relational data model but we do not know what to do with all these
...
@@ -357,7 +387,8 @@ attributes are taken from. We often write a relation scheme as
...
@@ -357,7 +387,8 @@ attributes are taken from. We often write a relation scheme as
<itemizedlist>
<itemizedlist>
<listitem>
<listitem>
<para>
<para>
The <firstterm>Relational Algebra</firstterm> which is an algebraic notation,
The <firstterm>Relational Algebra</firstterm> which is an
algebraic notation,
where queries are expressed by applying specialized operators to the
where queries are expressed by applying specialized operators to the
relations.
relations.
</para>
</para>
...
@@ -365,7 +396,8 @@ attributes are taken from. We often write a relation scheme as
...
@@ -365,7 +396,8 @@ attributes are taken from. We often write a relation scheme as
<listitem>
<listitem>
<para>
<para>
The <firstterm>Relational Calculus</firstterm> which is a logical notation,
The <firstterm>Relational Calculus</firstterm> which is a
logical notation,
where queries are expressed by formulating some logical restrictions
where queries are expressed by formulating some logical restrictions
that the tuples in the answer must satisfy.
that the tuples in the answer must satisfy.
</para>
</para>
...
@@ -383,7 +415,8 @@ attributes are taken from. We often write a relation scheme as
...
@@ -383,7 +415,8 @@ attributes are taken from. We often write a relation scheme as
<itemizedlist>
<itemizedlist>
<listitem>
<listitem>
<para>
<para>
SELECT (σ): extracts <firstterm>tuples</firstterm> from a relation that
SELECT (σ): extracts <firstterm>tuples</firstterm> from
a relation that
satisfy a given restriction. Let <parameter>R</parameter> be a
satisfy a given restriction. Let <parameter>R</parameter> be a
table that contains an attribute
table that contains an attribute
<parameter>A</parameter>.
<parameter>A</parameter>.
...
@@ -441,10 +474,12 @@ attributes are taken from. We often write a relation scheme as
...
@@ -441,10 +474,12 @@ attributes are taken from. We often write a relation scheme as
INTERSECT (∩): builds the set-theoretic intersection of two
INTERSECT (∩): builds the set-theoretic intersection of two
tables. Given the tables <classname>R</classname> and
tables. Given the tables <classname>R</classname> and
<classname>S</classname>,
<classname>S</classname>,
<classname>R</classname> ∪ <classname>S</classname> is the set of tuples
<classname>R</classname> ∪ <classname>S</classname> is the
set of tuples
that are in <classname>R</classname> and in
that are in <classname>R</classname> and in
<classname>S</classname>.
<classname>S</classname>.
We again require that <classname>R</classname> and <classname>S</classname> have the
We again require that <classname>R</classname> and
<classname>S</classname> have the
same arity.
same arity.
</para>
</para>
</listitem>
</listitem>
...
@@ -455,7 +490,8 @@ attributes are taken from. We often write a relation scheme as
...
@@ -455,7 +490,8 @@ attributes are taken from. We often write a relation scheme as
two tables. Let <classname>R</classname> and <classname>S</classname>
two tables. Let <classname>R</classname> and <classname>S</classname>
again be two tables with the same
again be two tables with the same
arity. <classname>R</classname> - <classname>S</classname>
arity. <classname>R</classname> - <classname>S</classname>
is the set of tuples in <classname>R</classname> but not in <classname>S</classname>.
is the set of tuples in <classname>R</classname> but not in
<classname>S</classname>.
</para>
</para>
</listitem>
</listitem>
...
@@ -672,9 +708,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
...
@@ -672,9 +708,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
the one underlying the most relational languages. For a detailed
the one underlying the most relational languages. For a detailed
discussion on <acronym>DRC</acronym> (and also
discussion on <acronym>DRC</acronym> (and also
<acronym>TRC</acronym>) see
<acronym>TRC</acronym>) see
[<xref linkend="DATE94" endterm="DATE94">]
<xref linkend="DATE94" endterm="DATE94">
or
or
[<xref linkend="ULL88" endterm="ULL88">]
.
<xref linkend="ULL88" endterm="ULL88">
.
</para>
</para>
</sect2>
</sect2>
...
@@ -727,9 +763,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
...
@@ -727,9 +763,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
algorithm</quote>) by which an arbitrary expression of the relational
algorithm</quote>) by which an arbitrary expression of the relational
calculus can be reduced to a semantically equivalent expression of
calculus can be reduced to a semantically equivalent expression of
relational algebra. For a more detailed discussion on that refer to
relational algebra. For a more detailed discussion on that refer to
[<xref linkend="DATE94" endterm="DATE94">]
<xref linkend="DATE94" endterm="DATE94">
and
and
[<xref linkend="ULL88" endterm="ULL88">]
.
<xref linkend="ULL88" endterm="ULL88">
.
</para>
</para>
<para>
<para>
...
@@ -750,9 +786,11 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
...
@@ -750,9 +786,11 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
<acronym>SQL</acronym> is based on the tuple
<acronym>SQL</acronym> is based on the tuple
relational calculus. As a result every query that can be formulated
relational calculus. As a result every query that can be formulated
using the tuple relational calculus (or equivalently, relational
using the tuple relational calculus (or equivalently, relational
algebra) can also be formulated using <acronym>SQL</acronym>. There are, however,
algebra) can also be formulated using
<acronym>SQL</acronym>. There are, however,
capabilities beyond the scope of relational algebra or calculus. Here
capabilities beyond the scope of relational algebra or calculus. Here
is a list of some additional features provided by <acronym>SQL</acronym> that are not
is a list of some additional features provided by
<acronym>SQL</acronym> that are not
part of relational algebra or calculus:
part of relational algebra or calculus:
<itemizedlist>
<itemizedlist>
...
@@ -764,7 +802,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
...
@@ -764,7 +802,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
<listitem>
<listitem>
<para>
<para>
Arithmetic capability: In <acronym>SQL</acronym> it is possible to involve
Arithmetic capability: In <acronym>SQL</acronym> it is possible
to involve
arithmetic operations as well as comparisons, e.g.
arithmetic operations as well as comparisons, e.g.
A < B + 3.
A < B + 3.
...
@@ -787,7 +826,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
...
@@ -787,7 +826,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
<para>
<para>
Aggregate Functions: Operations such as
Aggregate Functions: Operations such as
<firstterm>average</firstterm>, <firstterm>sum</firstterm>,
<firstterm>average</firstterm>, <firstterm>sum</firstterm>,
<firstterm>max</firstterm>, etc. can be applied to columns of a relation to
<firstterm>max</firstterm>, etc. can be applied to columns of a
relation to
obtain a single quantity.
obtain a single quantity.
</para>
</para>
</listitem>
</listitem>
...
@@ -918,7 +958,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
...
@@ -918,7 +958,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
Note that the word DOUBLE after the keyword AS is the new title of the
Note that the word DOUBLE after the keyword AS is the new title of the
second column. This technique can be used for every element of the
second column. This technique can be used for every element of the
target list to assign a new title to the resulting column. This new title
target list to assign a new title to the resulting
column. This new title
is often referred to as alias. The alias cannot be used throughout the
is often referred to as alias. The alias cannot be used throughout the
rest of the query.
rest of the query.
</para>
</para>
...
@@ -1508,8 +1549,10 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
...
@@ -1508,8 +1549,10 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
<para>
<para>
A view may be regarded as a <firstterm>virtual table</firstterm>,
A view may be regarded as a <firstterm>virtual table</firstterm>,
i.e. a table that
i.e. a table that
does not <emphasis>physically</emphasis> exist in the database but looks to the user
does not <emphasis>physically</emphasis> exist in the database
as if it does. By contrast, when we talk of a <firstterm>base table</firstterm> there is
but looks to the user
as if it does. By contrast, when we talk of a
<firstterm>base table</firstterm> there is
really a physically stored counterpart of each row of the table
really a physically stored counterpart of each row of the table
somewhere in the physical storage.
somewhere in the physical storage.
</para>
</para>
...
@@ -1550,7 +1593,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
...
@@ -1550,7 +1593,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
<para>
<para>
Let the following view definition be given (we use
Let the following view definition be given (we use
the tables from <xref linkend="supplier-fig" endterm="supplier-fig"> again):
the tables from
<xref linkend="supplier-fig" endterm="supplier-fig"> again):
<programlisting>
<programlisting>
CREATE VIEW London_Suppliers
CREATE VIEW London_Suppliers
...
@@ -1587,7 +1631,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
...
@@ -1587,7 +1631,8 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
<emphasis>hidden</emphasis>
<emphasis>hidden</emphasis>
access to the base tables SUPPLIER, SELLS and PART first. It
access to the base tables SUPPLIER, SELLS and PART first. It
does so by executing the query given in the view definition against
does so by executing the query given in the view definition against
those base tables. After that the additional qualifications (given in the
those base tables. After that the additional qualifications
(given in the
query against the view) can be applied to obtain the resulting
query against the view) can be applied to obtain the resulting
table.
table.
</para>
</para>
...
@@ -1746,11 +1791,12 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
...
@@ -1746,11 +1791,12 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
<!--
<!--
section
section
<xref linkend="view-impl" endterm="view-impl">.
<xref linkend="view-impl" endterm="view-impl">.
<citetitle>SIM98</citetitle>
-->
-->
<
citetitle>SIM98</citetitle
>
<
xref linkend="SIM98" endterm="SIM98"
>
for a more detailed
for a more detailed
description). For more information about system catalogs refer to
description). For more information about system catalogs refer to
<
citetitle>DATE</citetitle
>.
<
xref linkend="DATE94" endterm="DATE94"
>.
</para>
</para>
</sect2>
</sect2>
...
@@ -1815,10 +1861,10 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
...
@@ -1815,10 +1861,10 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
<para>
<para>
For a detailed discussion on embedded <acronym>SQL</acronym>
For a detailed discussion on embedded <acronym>SQL</acronym>
refer to
refer to
[<xref linkend="DATE97" endterm="DATE97">]
,
<xref linkend="DATE97" endterm="DATE97">
,
[<xref linkend="DATE94" endterm="DATE94">]
,
<xref linkend="DATE94" endterm="DATE94">
,
or
or
[<xref linkend="ULL88" endterm="ULL88">]
.
<xref linkend="ULL88" endterm="ULL88">
.
</para>
</para>
</sect2>
</sect2>
</sect1>
</sect1>
...
...
doc/src/sgml/start.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.
9 2000/03/31 03:27:41
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.
10 2000/04/07 13:30:58
thomas Exp $
-->
-->
<Chapter Id="start">
<chapter id="start">
<Title>Getting Started</Title>
<title>Getting Started</title>
<Abstract>
<abstract>
<Para>
<para>
How to begin work with <ProductName>Postgres</ProductName> for a new user.
How to begin work with <productname>Postgres</productname> for a new user.
</Para>
</para>
</Abstract>
</abstract>
<Para>
<para>
Some of the steps required to use <ProductName>Postgres</ProductName>
Some of the steps required to use <productname>Postgres</productname>
can be performed by any Postgres user, and some must be done by
can be performed by any Postgres user, and some must be done by
the site database administrator. This site administrator
the site database administrator. This site administrator
is the person who installed the software, created
is the person who installed the software, created
the database directories and started the <Application>postmaster</Application>
the database directories and started the
process. This person does not have to be the Unix
<application>postmaster</application>
superuser (<Quote>root</Quote>)
process. This person does not have to be the Unix
or the computer system administrator; a person can install and use
superuser (<quote>root</quote>)
<ProductName>Postgres</ProductName> without any special accounts or privileges.
or the computer system administrator; a person can install and use
</Para>
<productname>Postgres</productname> without any special accounts or
privileges.
<Para>
</para>
If you are installing <ProductName>Postgres</ProductName> yourself, then
refer to the Administrator's Guide for instructions on installation, and return
<para>
to this guide when the installation is complete.
If you are installing <productname>Postgres</productname> yourself, then
</Para>
refer to the Administrator's Guide for instructions on
installation, and return
<Para>
to this guide when the installation is complete.
Throughout this manual, any examples that begin with
</para>
the character <Quote>%</Quote> are commands that should be typed
at the Unix shell prompt. Examples that begin with the
<para>
character <Quote>*</Quote> are commands in the Postgres query
Throughout this manual, any examples that begin with
language, Postgres <Acronym>SQL</Acronym>.
the character <quote>%</quote> are commands that should be typed
</Para>
at the Unix shell prompt. Examples that begin with the
character <quote>*</quote> are commands in the Postgres query
<Sect1>
language, Postgres <acronym>SQL</acronym>.
<Title>Setting Up Your Environment</Title>
</para>
<Para>
<sect1>
This section discusses how to set up
<title>Setting Up Your Environment</title>
your own environment so that you can use frontend
applications. We assume <ProductName>Postgres</ProductName> has already been
<para>
successfully installed and started; refer to the Administrator's Guide
This section discusses how to set up
and the installation notes
your own environment so that you can use frontend
for how to install Postgres.
applications. We assume <productname>Postgres</productname> has
</Para>
already been
successfully installed and started; refer to the Administrator's Guide
<Para>
and the installation notes
<ProductName>Postgres</ProductName> is a client/server application. As a user,
for how to install Postgres.
you only need access to the client portions of the installation (an example
</para>
of a client application is the interactive monitor <Application>psql</Application>).
For simplicity,
<para>
we will assume that <ProductName>Postgres</ProductName> has been installed in the
<productname>Postgres</productname> is a client/server
directory <FileName>/usr/local/pgsql</FileName>. Therefore, wherever
application. As a user,
you see the directory <FileName>/usr/local/pgsql</FileName> you should
you only need access to the client portions of the installation
substitute the name of the directory where <ProductName>Postgres</ProductName> is
(an example
actually installed.
of a client application is the interactive monitor
All <ProductName>Postgres</ProductName> commands are installed in the directory
<application>psql</application>).
<FileName>/usr/local/pgsql/bin</FileName>. Therefore, you should add
For simplicity,
this directory to your shell command path. If you use
we will assume that <productname>Postgres</productname> has been
a variant of the Berkeley C shell, such as csh or tcsh,
installed in the
you would add
directory <filename>/usr/local/pgsql</filename>. Therefore, wherever
<ProgramListing>
you see the directory <filename>/usr/local/pgsql</filename> you should
substitute the name of the directory where
<productname>Postgres</productname> is
actually installed.
All <productname>Postgres</productname> commands are installed in
the directory
<filename>/usr/local/pgsql/bin</filename>. Therefore, you should add
this directory to your shell command path. If you use
a variant of the Berkeley C shell, such as csh or tcsh,
you would add
<programlisting>
% set path = ( /usr/local/pgsql/bin path )
% set path = ( /usr/local/pgsql/bin path )
</ProgramListing>
</programlisting>
in the <FileName>.login</FileName> file in your home directory. If you use
a variant of the Bourne shell, such as sh, ksh, or
in the <filename>.login</filename> file in your home directory.
bash, then you would add
If you use
<ProgramListing>
a variant of the Bourne shell, such as sh, ksh, or
bash, then you would add
<programlisting>
% PATH=/usr/local/pgsql/bin:$PATH
% PATH=/usr/local/pgsql/bin:$PATH
% export PATH
% export PATH
</ProgramListing>
</programlisting>
to the .profile file in your home directory.
From now on, we will assume that you have added the
to the .profile file in your home directory.
<ProductName>Postgres</ProductName> bin directory to your path. In addition, we
From now on, we will assume that you have added the
will make frequent reference to <Quote>setting a shell
<productname>Postgres</productname> bin directory to your path.
variable</Quote> or <Quote>setting an environment variable</Quote> throughout
In addition, we
this document. If you did not fully understand the
will make frequent reference to <quote>setting a shell
last paragraph on modifying your search path, you
variable</quote> or <quote>setting an environment
should consult the Unix manual pages that describe your
variable</quote> throughout
shell before going any further.
this document. If you did not fully understand the
</Para>
last paragraph on modifying your search path, you
should consult the Unix manual pages that describe your
<Para>
shell before going any further.
If your site administrator has not set things up in the
</para>
default way, you may have some more work to do. For example, if the database
server machine is a remote machine, you
<para>
will need to set the <Acronym>PGHOST</Acronym> environment variable to the name
If your site administrator has not set things up in the
of the database server machine. The environment variable
default way, you may have some more work to do. For example, if
<Acronym>PGPORT</Acronym> may also have to be set. The bottom line is this: if
the database
you try to start an application program and it complains
server machine is a remote machine, you
that it cannot connect to the <Application>postmaster</Application>,
will need to set the <acronym>PGHOST</acronym> environment
you should immediately consult your site administrator to make sure that your
variable to the name
environment is properly set up.
of the database server machine. The environment variable
</Para>
<acronym>PGPORT</acronym> may also have to be set. The bottom
line is this: if
</Sect1>
you try to start an application program and it complains
that it cannot connect to the <application>postmaster</application>,
<Sect1>
you should immediately consult your site administrator to make
<Title>Starting the Interactive Monitor (psql)</Title>
sure that your
environment is properly set up.
<Para>
</para>
Assuming that your site administrator has properly
started the <Application>postmaster</Application> process and authorized you to
</sect1>
use the database, you (as a user) may begin to start up
applications. As previously mentioned, you should add
<sect1>
<FileName>/usr/local/pgsql/bin</FileName> to your shell search path.
<title>Starting the Interactive Monitor (psql)</title>
In most cases, this is all you should have to do in
terms of preparation.
<para>
</Para>
Assuming that your site administrator has properly
started the <application>postmaster</application> process and
<Para>
authorized you to
As of <ProductName>Postgres</ProductName> v6.3, two different styles of connections
use the database, you (as a user) may begin to start up
are supported. The site administrator will have chosen to allow TCP/IP network connections
applications. As previously mentioned, you should add
or will have restricted database access to local (same-machine) socket connections only.
<filename>/usr/local/pgsql/bin</filename> to your shell search path.
These choices become significant if you encounter problems in connecting to a database.
In most cases, this is all you should have to do in
</Para>
terms of preparation.
</para>
<Para>
If you get the following error message from a <ProductName>Postgres</ProductName>
<para>
command (such as <Application>psql</Application> or <Application>createdb</Application>):
Two different styles of connections
are supported. The site administrator will have chosen to allow
<ProgramListing>
TCP/IP network connections
or will have restricted database access to local (same-machine)
socket connections only.
These choices become significant if you encounter problems in
connecting to a database, since you will want to confirm that you
are choosing an allowed connection option.
</para>
<para>
If you get the following error message from a
<productname>Postgres</productname>
command (such as <application>psql</application> or
<application>createdb</application>):
<programlisting>
% psql template1
% psql template1
Connection to database 'postgres' failed.
Connection to database 'postgres' failed.
connectDB() failed: Is the postmaster running and accepting connections
connectDB() failed: Is the postmaster running and accepting connections
at 'UNIX Socket' on port '5432'?
at 'UNIX Socket' on port '5432'?
</ProgramL
isting>
</programl
isting>
or
or
<ProgramL
isting>
<programl
isting>
% psql -h localhost template1
% psql -h localhost template1
Connection to database 'postgres' failed.
Connection to database 'postgres' failed.
connectDB() failed: Is the postmaster running and accepting TCP/IP
connectDB() failed: Is the postmaster running and accepting TCP/IP
(with -i) connections at 'localhost' on port '5432'?
(with -i) connections at 'localhost' on port '5432'?
</ProgramListing>
</programlisting>
it is usually because (1) the <Application>postmaster</Application> is not running,
it is usually because
or (2) you are attempting to connect to the wrong server host.
If you get the following error message:
<itemizedlist mark="bullet" spacing="compact">
<listitem>
<ProgramListing>
<para>
the <application>postmaster</application> is not running,
or
</para>
</listitem>
<listitem>
<para>
you are attempting to connect to the wrong server host.
</para>
</listitem>
</itemizedlist>
</para>
<para>
If you get the following error message:
<programlisting>
FATAL 1:Feb 17 23:19:55:process userid (2360) != database owner (268)
FATAL 1:Feb 17 23:19:55:process userid (2360) != database owner (268)
</ProgramListing>
</programlisting>
it means that the site administrator started the <Application>postmaster</Application>
it means that the site administrator started the
as the wrong user. Tell him to restart it as
<application>postmaster</application>
the <ProductName>Postgres</ProductName> superuser.
as the wrong user. Tell him to restart it as
</Para>
the <productname>Postgres</productname> superuser.
</Sect1>
</para>
</sect1>
<Sect1>
<Title>Managing a Database</Title>
<sect1>
<title>Managing a Database</title>
<Para>
Now that <ProductName>Postgres</ProductName> is up and running we can create some
<para>
databases to experiment with. Here, we describe the
Now that <productname>Postgres</productname> is up and running we
basic commands for managing a database.
can create some
</Para>
databases to experiment with. Here, we describe the
basic commands for managing a database.
<Para>
</para>
Most <ProductName>Postgres</ProductName>
applications assume that the database name, if not specified, is the same as the name on your computer
<para>
account.
Most <productname>Postgres</productname>
</Para>
applications assume that the database name, if not specified, is
the same as the name on your computer
<Para>
account.
If your database administrator has set up your account without database creation privileges,
</para>
then she should have told you what the name of your database is. If this is the case, then you
can skip the sections on creating and destroying databases.
<para>
</Para>
If your database administrator has set up your account without
database creation privileges,
<Sect2>
then she should have told you what the name of your database is. If
<Title>Creating a Database</Title>
this is the case, then you
can skip the sections on creating and destroying databases.
<Para>
</para>
Let's say you want to create a database named <Database>mydb</Database>.
<sect2>
<title>Creating a Database</title>
<para>
Let's say you want to create a database named
<database>mydb</database>.
You can do this with the following command:
You can do this with the following command:
<ProgramL
isting>
<programl
isting>
% createdb mydb
% createdb mydb
</ProgramListing>
</programlisting>
</Para>
</para>
<Para>
<para>
If you do not have the privileges required to create a database, you will see
If you do not have the privileges required to create a database,
the following:
you will see
<ProgramListing>
the following:
<programlisting>
% createdb mydb
% createdb mydb
WARN:user "your username" is not allowed to create/destroy databases
WARN:user "your username" is not allowed to create/destroy databases
createdb: database creation failed on mydb.
createdb: database creation failed on mydb.
</ProgramL
isting>
</programl
isting>
</P
ara>
</p
ara>
<Para>
<para>
<ProductName>Postgres</ProductName> allows you to create any number of databases
<productname>Postgres</productname> allows you to create any
number of databases
at a given site and you automatically become the
at a given site and you automatically become the
database administrator of the database you just created. Database names must have an alphabetic first
database administrator of the database you just created.
Database names must have an alphabetic first
character and are limited to 32 characters in length.
character and are limited to 32 characters in length.
Not every user has authorization to become a database
Not every user has authorization to become a database
administrator. If <ProductName>Postgres</ProductName> refuses to create databases
administrator. If <productname>Postgres</productname> refuses to
create databases
for you, then the site administrator needs to grant you
for you, then the site administrator needs to grant you
permission to create databases. Consult your site
permission to create databases. Consult your site
administrator if this occurs.
administrator if this occurs.
</P
ara>
</p
ara>
</S
ect2>
</s
ect2>
<S
ect2>
<s
ect2>
<Title>Accessing a Database</T
itle>
<title>Accessing a Database</t
itle>
<P
ara>
<p
ara>
Once you have constructed a database, you can access it
Once you have constructed a database, you can access it
by:
by:
<ItemizedList Mark="bullet" Spacing="compact">
<itemizedlist spacing="compact" mark="bullet">
<ListItem>
<listitem>
<Para>
<para>
running the <ProductName>Postgres</ProductName> terminal monitor programs
Running the <productname>Postgres</productname> terminal
(e.g. <Application>psql</Application>) which allows you to interactively
monitor programs
enter, edit, and execute <Acronym>SQL</Acronym> commands.
(e.g. <application>psql</application>) which allows you to
</Para>
interactively
</ListItem>
enter, edit, and execute <acronym>SQL</acronym> commands.
<ListItem>
</para>
<Para>
</listitem>
writing a <Acronym>C</Acronym> program using the LIBPQ subroutine
library. This allows you to submit <Acronym>SQL</Acronym> commands
<listitem>
from <Acronym>C</Acronym> and get answers and status messages back to
<para>
Using an existing native frontend tool like
<application>pgaccess</application> or
<application>ApplixWare</application> (via
<acronym>ODBC</acronym>) to create and manipulate a
database.
</para>
</listitem>
<listitem>
<para>
Using a language like perl or tcl which has a supported
interface for <productname>Postgres</productname>. Some of
these languages also have convenient and powerful GUI toolkits
which can help you construct custom
applications. <application>pgaccess</application>, mentioned
above, is one such application written in tk/tcl and can be
used as an example.
</para>
</listitem>
<listitem>
<para>
Writing a <acronym>C</acronym> program using
the LIBPQ subroutine
library. This allows you to submit
<acronym>SQL</acronym> commands
from <acronym>C</acronym> and get answers and
status messages back to
your program. This interface is discussed further
your program. This interface is discussed further
in <citetitle>The PostgreSQL Programmer's Guide</citetitle>.
in <citetitle>The PostgreSQL Programmer's Guide</citetitle>.
</P
ara>
</p
ara>
</ListI
tem>
</listi
tem>
</ItemizedL
ist>
</itemizedl
ist>
You might want to start up <Application>psql</A
pplication>,
You might want to start up <application>psql</a
pplication>,
to try out the examples in this manual.
to try out the examples in this manual.
It can be activated for the <Database>mydb</D
atabase>
It can be activated for the <database>mydb</d
atabase>
database by typing the command:
database by typing the command:
<ProgramL
isting>
<programl
isting>
% psql mydb
% psql mydb
</ProgramL
isting>
</programl
isting>
You will be greeted with the following message:
You will be greeted with the following message:
<ProgramL
isting>
<programl
isting>
Welcome to the POSTGRESQL interactive sql monitor:
Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
...
@@ -254,71 +337,79 @@ Welcome to the POSTGRESQL interactive sql monitor:
...
@@ -254,71 +337,79 @@ Welcome to the POSTGRESQL interactive sql monitor:
You are currently connected to the database: template1
You are currently connected to the database: template1
mydb=>
mydb=>
</ProgramL
isting>
</programl
isting>
</P
ara>
</p
ara>
<P
ara>
<p
ara>
This prompt indicates that the terminal monitor is listening
This prompt indicates that the terminal monitor is listening
to you and that you can type <Acronym>SQL</A
cronym> queries into a
to you and that you can type <acronym>SQL</a
cronym> queries into a
workspace maintained by the terminal monitor.
workspace maintained by the terminal monitor.
The <Application>psql</Application> program responds to escape codes that begin
The <application>psql</application> program responds to escape
with the backslash character, <Quote>\</Quote> For example, you
codes that begin
with the backslash character, <quote>\</quote> For example, you
can get help on the syntax of various
can get help on the syntax of various
<ProductName>Postgres</ProductName> <Acronym>SQL</Acronym> commands by typing:
<productname>Postgres</productname> <acronym>SQL</acronym>
<ProgramListing>
commands by typing:
<programlisting>
mydb=> \h
mydb=> \h
</ProgramListing>
</programlisting>
</para>
<para>
Once you have finished entering your queries into the
Once you have finished entering your queries into the
workspace, you can pass the contents of the workspace
workspace, you can pass the contents of the workspace
to the <
ProductName>Postgres</ProductN
ame> server by typing:
to the <
productname>Postgres</productn
ame> server by typing:
<ProgramL
isting>
<programl
isting>
mydb=> \g
mydb=> \g
</ProgramL
isting>
</programl
isting>
This tells the server to process the query. If you
This tells the server to process the query. If you
terminate your query with a semicolon, the <
Quote>\g</Q
uote> is not
terminate your query with a semicolon, the <
quote>\g</q
uote> is not
necessary.
necessary.
<Application>psql</Application> will automatically process semicolon terminated queries.
<application>psql</application> will automatically process
semicolon terminated queries.
To read queries from a file, say myFile, instead of
To read queries from a file, say myFile, instead of
entering them interactively, type:
entering them interactively, type:
<ProgramL
isting>
<programl
isting>
mydb=> \i fileName
mydb=> \i fileName
</ProgramL
isting>
</programl
isting>
To get out of <
Application>psql</A
pplication> and return to Unix, type
To get out of <
application>psql</a
pplication> and return to Unix, type
<ProgramL
isting>
<programl
isting>
mydb=> \q
mydb=> \q
</ProgramL
isting>
</programl
isting>
and <Application>psql</Application> will quit and return you to your command
and <application>psql</application> will quit and return
shell. (For more escape codes, type <Command>\h</Command> at the monitor
you to your command
prompt.)
shell. (For more escape codes, type <command>\h</command> at the
monitor prompt.)
White space (i.e., spaces, tabs and newlines) may be
White space (i.e., spaces, tabs and newlines) may be
used freely in <Acronym>SQL</Acronym> queries. Single-line comments are denoted by
used freely in <acronym>SQL</acronym> queries. Single-line
<Quote>--</Quote>. Everything after the dashes up to the end of the
comments are denoted by
<quote>--</quote>. Everything after the dashes up to the end of the
line is ignored. Multiple-line comments, and comments within a line,
line is ignored. Multiple-line comments, and comments within a line,
are denoted by <
Quote>/* ... */</Q
uote>
are denoted by <
quote>/* ... */</q
uote>
</P
ara>
</p
ara>
</S
ect2>
</s
ect2>
<S
ect2>
<s
ect2>
<Title>Destroying a Database</T
itle>
<title>Destroying a Database</t
itle>
<P
ara>
<p
ara>
If you are the database administrator for the database
If you are the database administrator for the database
<Database>mydb</Database>, you can destroy it using the following Unix command:
<database>mydb</database>, you can destroy it using the
<ProgramListing>
following Unix command:
<programlisting>
% dropdb mydb
% dropdb mydb
</ProgramL
isting>
</programl
isting>
This action physically removes all of the Unix files
This action physically removes all of the Unix files
associated with the database and cannot be undone, so
associated with the database and cannot be undone, so
this should only be done with a great deal of forethought.
this should only be done with a great deal of forethought.
</P
ara>
</p
ara>
</S
ect2>
</s
ect2>
</S
ect1>
</s
ect1>
</C
hapter>
</c
hapter>
<!-- Keep this comment at the end of the file
<!-- Keep this comment at the end of the file
Local variables:
Local variables:
...
...
doc/src/sgml/y2k.sgml
View file @
30e355fc
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/y2k.sgml,v 1.
5 2000/03/31 03:27:42
thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/y2k.sgml,v 1.
6 2000/04/07 13:30:58
thomas Exp $
-->
-->
<sect1 id="y2k">
<sect1 id="y2k">
...
@@ -11,7 +11,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/y2k.sgml,v 1.5 2000/03/31 03:27:42 th
...
@@ -11,7 +11,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/y2k.sgml,v 1.5 2000/03/31 03:27:42 th
<para>
<para>
Written by
Written by
<ulink url="mailto:lockhart@alumni.caltech.edu">Thomas Lockhart</ulink>
<ulink url="mailto:lockhart@alumni.caltech.edu">Thomas Lockhart</ulink>
on 1998-10-22.
on 1998-10-22.
Updated 2000-03-31.
</para>
</para>
</note>
</note>
...
@@ -25,7 +25,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/y2k.sgml,v 1.5 2000/03/31 03:27:42 th
...
@@ -25,7 +25,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/y2k.sgml,v 1.5 2000/03/31 03:27:42 th
<itemizedlist>
<itemizedlist>
<listitem>
<listitem>
<para>
<para>
The author of this statement, a volunteer on the <productname>Postgres</productname>
The author of this statement, a volunteer on the
<productname>Postgres</productname>
support team since November, 1996, is not aware of
support team since November, 1996, is not aware of
any problems in the <productname>Postgres</productname> code base related
any problems in the <productname>Postgres</productname> code base related
to time transitions around Jan 1, 2000 (Y2K).
to time transitions around Jan 1, 2000 (Y2K).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment