Commit 375dcf9c authored by Tom Lane's avatar Tom Lane

Fix a few typos, grammatical problems, etc in new tutorial material.

Overall a really nice job here, Peter ...
parent 9b03776f
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.22 2001/09/02 23:27:49 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.23 2001/11/19 05:37:53 tgl Exp $
--> -->
<chapter id="tutorial-advanced"> <chapter id="tutorial-advanced">
...@@ -10,9 +10,9 @@ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.22 2001/09/02 23:27:49 pe ...@@ -10,9 +10,9 @@ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.22 2001/09/02 23:27:49 pe
<para> <para>
In the previous chapter we have covered the basics of using In the previous chapter we have covered the basics of using
<acronym>SQL</acronym> to store and access your data in a <acronym>SQL</acronym> to store and access your data in
<productname>PostgreSQL</productname>. We will now discuss some <productname>PostgreSQL</productname>. We will now discuss some
more advanced features of <acronym>SQL</acronym> that simplify the more advanced features of <acronym>SQL</acronym> that simplify
management and prevent loss or corruption of your data. Finally, management and prevent loss or corruption of your data. Finally,
we will look at some <productname>PostgreSQL</productname> we will look at some <productname>PostgreSQL</productname>
extensions. extensions.
...@@ -82,7 +82,7 @@ SELECT * FROM myview; ...@@ -82,7 +82,7 @@ SELECT * FROM myview;
</indexterm> </indexterm>
<para> <para>
Recall the <classname>weather</classname> and the Recall the <classname>weather</classname> and
<classname>cities</classname> tables from <xref <classname>cities</classname> tables from <xref
linkend="tutorial-sql">. Consider the following problem: You linkend="tutorial-sql">. Consider the following problem: You
want to make sure that no one can insert rows in the want to make sure that no one can insert rows in the
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.20 2001/11/08 23:34:33 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.21 2001/11/19 05:37:53 tgl Exp $
--> -->
<chapter id="tutorial-sql"> <chapter id="tutorial-sql">
...@@ -26,7 +26,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.20 2001/11/08 23:34:33 peter ...@@ -26,7 +26,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.20 2001/11/08 23:34:33 peter
</para> </para>
<para> <para>
Examples in this manual can also be found in source distribution Examples in this manual can also be found in the
<productname>PostgreSQL</productname> source distribution
in the directory <filename>src/tutorial/</filename>. Refer to the in the directory <filename>src/tutorial/</filename>. Refer to the
<filename>README</filename> file in that directory for how to use <filename>README</filename> file in that directory for how to use
them. To start the tutorial, do the following: them. To start the tutorial, do the following:
...@@ -42,7 +43,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.20 2001/11/08 23:34:33 peter ...@@ -42,7 +43,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.20 2001/11/08 23:34:33 peter
</screen> </screen>
The <literal>\i</literal> command reads in commands from the The <literal>\i</literal> command reads in commands from the
specified files. The <literal>-s</literal> option puts you in specified file. The <literal>-s</literal> option puts you in
single step mode which pauses before sending a query to the single step mode which pauses before sending a query to the
server. The commands used in this section are in the file server. The commands used in this section are in the file
<filename>basics.sql</filename>. <filename>basics.sql</filename>.
...@@ -126,7 +127,7 @@ CREATE TABLE weather ( ...@@ -126,7 +127,7 @@ CREATE TABLE weather (
differently than above, or even all on one line. Two dashes differently than above, or even all on one line. Two dashes
(<quote><literal>--</literal></quote>) introduce comments. (<quote><literal>--</literal></quote>) introduce comments.
Whatever follows them is ignored up to the end of the line. SQL Whatever follows them is ignored up to the end of the line. SQL
is also case insensitive about key words and identifiers, except is case insensitive about key words and identifiers, except
when identifiers are double-quoted to preserve the case (not done when identifiers are double-quoted to preserve the case (not done
above). above).
</para> </para>
...@@ -148,7 +149,7 @@ CREATE TABLE weather ( ...@@ -148,7 +149,7 @@ CREATE TABLE weather (
precision</type>, <type>char(<replaceable>N</>)</type>, precision</type>, <type>char(<replaceable>N</>)</type>,
<type>varchar(<replaceable>N</>)</type>, <type>date</type>, <type>varchar(<replaceable>N</>)</type>, <type>date</type>,
<type>time</type>, <type>timestamp</type>, and <type>time</type>, <type>timestamp</type>, and
<type>interval</type> as well as other types of general utility <type>interval</type>, as well as other types of general utility
and a rich set of geometric types. and a rich set of geometric types.
<productname>PostgreSQL</productname> can be customized with an <productname>PostgreSQL</productname> can be customized with an
arbitrary number of user-defined data types. Consequently, type arbitrary number of user-defined data types. Consequently, type
...@@ -165,7 +166,7 @@ CREATE TABLE cities ( ...@@ -165,7 +166,7 @@ CREATE TABLE cities (
location point location point
); );
</programlisting> </programlisting>
The <type>point</type> type is such a The <type>point</type> type is an example of a
<productname>PostgreSQL</productname>-specific data type. <productname>PostgreSQL</productname>-specific data type.
</para> </para>
...@@ -221,7 +222,7 @@ INSERT INTO cities VALUES ('San Francisco', '(-194.0, 53.0)'); ...@@ -221,7 +222,7 @@ INSERT INTO cities VALUES ('San Francisco', '(-194.0, 53.0)');
INSERT INTO weather (city, temp_lo, temp_hi, prcp, date) INSERT INTO weather (city, temp_lo, temp_hi, prcp, date)
VALUES ('San Francisco', 43, 57, 0.0, '1994-11-29'); VALUES ('San Francisco', 43, 57, 0.0, '1994-11-29');
</programlisting> </programlisting>
You can also list the columns in a different order if you wish or You can list the columns in a different order if you wish or
even omit some columns, e.g., unknown precipitation: even omit some columns, e.g., unknown precipitation:
<programlisting> <programlisting>
INSERT INTO weather (date, city, temp_hi, temp_lo) INSERT INTO weather (date, city, temp_hi, temp_lo)
...@@ -279,7 +280,7 @@ COPY weather FROM '/home/user/weather.txt'; ...@@ -279,7 +280,7 @@ COPY weather FROM '/home/user/weather.txt';
<programlisting> <programlisting>
SELECT * FROM weather; SELECT * FROM weather;
</programlisting> </programlisting>
(where <literal>*</literal> means <quote>all columns</quote>) and (here <literal>*</literal> means <quote>all columns</quote>) and
the output should be: the output should be:
<screen> <screen>
city | temp_lo | temp_hi | prcp | date city | temp_lo | temp_hi | prcp | date
...@@ -373,9 +374,9 @@ SELECT DISTINCT city ...@@ -373,9 +374,9 @@ SELECT DISTINCT city
of the same or different tables at one time is called a of the same or different tables at one time is called a
<firstterm>join</firstterm> query. As an example, say you wish to <firstterm>join</firstterm> query. As an example, say you wish to
list all the weather records together with the location of the list all the weather records together with the location of the
associated city. In effect, we need to compare the city column of associated city. To do that, we need to compare the city column of
each row of the weather table with the name column of all rows in each row of the weather table with the name column of all rows in
the cities table. the cities table, and select the pairs of rows where these values match.
<note> <note>
<para> <para>
This is only a conceptual model. The actual join may This is only a conceptual model. The actual join may
...@@ -409,7 +410,7 @@ SELECT * ...@@ -409,7 +410,7 @@ SELECT *
There is no result row for the city of Hayward. This is There is no result row for the city of Hayward. This is
because there is no matching entry in the because there is no matching entry in the
<classname>cities</classname> table for Hayward, so the join <classname>cities</classname> table for Hayward, so the join
cannot process the rows in the weather table. We will see ignores the unmatched rows in the weather table. We will see
shortly how this can be fixed. shortly how this can be fixed.
</para> </para>
</listitem> </listitem>
...@@ -478,7 +479,7 @@ SELECT * ...@@ -478,7 +479,7 @@ SELECT *
found we want some <quote>empty values</quote> to be substituted found we want some <quote>empty values</quote> to be substituted
for the <classname>cities</classname> table's columns. This kind for the <classname>cities</classname> table's columns. This kind
of query is called an <firstterm>outer join</firstterm>. (The of query is called an <firstterm>outer join</firstterm>. (The
joins we have seen to far are inner joins.) The command looks joins we have seen so far are inner joins.) The command looks
like this: like this:
<programlisting> <programlisting>
...@@ -493,12 +494,13 @@ SELECT * ...@@ -493,12 +494,13 @@ SELECT *
(3 rows) (3 rows)
</programlisting> </programlisting>
In particular, this query is a <firstterm>left outer This query is called a <firstterm>left outer
join</firstterm> because the table mentioned on the left of the join</firstterm> because the table mentioned on the left of the
join operator will have each of its rows in the output at least join operator will have each of its rows in the output at least
once, whereas the table on the right will only have those rows once, whereas the table on the right will only have those rows
output that match some row of the left table, and will have empty output that match some row of the left table. When outputting a
values substituted appropriately. left-table row for which there is no right-table match, empty (NULL)
values are substituted for the right-table columns.
</para> </para>
<formalpara> <formalpara>
...@@ -605,7 +607,11 @@ SELECT city FROM weather WHERE temp_lo = max(temp_lo); <lineannotation>WRONG ...@@ -605,7 +607,11 @@ SELECT city FROM weather WHERE temp_lo = max(temp_lo); <lineannotation>WRONG
but this will not work since the aggregate but this will not work since the aggregate
<function>max</function> cannot be used in the <function>max</function> cannot be used in the
<literal>WHERE</literal> clause. However, as is often the case <literal>WHERE</literal> clause. (This restriction exists because
the <literal>WHERE</literal> clause determines the rows that will
go into the aggregation stage; so it has to be evaluated before
aggregate functions are computed.)
However, as is often the case
the query can be restated to accomplish the intended result; here the query can be restated to accomplish the intended result; here
by using a <firstterm>subquery</firstterm>: by using a <firstterm>subquery</firstterm>:
...@@ -697,7 +703,7 @@ SELECT city, max(temp_lo) ...@@ -697,7 +703,7 @@ SELECT city, max(temp_lo)
</para> </para>
<para> <para>
Note that we can apply the city name restriction in Observe that we can apply the city name restriction in
<literal>WHERE</literal>, since it needs no aggregate. This is <literal>WHERE</literal>, since it needs no aggregate. This is
more efficient than adding the restriction to <literal>HAVING</literal>, more efficient than adding the restriction to <literal>HAVING</literal>,
because we avoid doing the grouping and aggregate calculations because we avoid doing the grouping and aggregate calculations
...@@ -718,7 +724,7 @@ SELECT city, max(temp_lo) ...@@ -718,7 +724,7 @@ SELECT city, max(temp_lo)
<command>UPDATE</command> command. <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 November 28, you may update the all off by 2 degrees as of November 28, you may update the
data as follow: data as follows:
<programlisting> <programlisting>
UPDATE weather UPDATE weather
...@@ -758,7 +764,7 @@ SELECT * FROM weather; ...@@ -758,7 +764,7 @@ SELECT * FROM weather;
DELETE FROM weather WHERE city = 'Hayward'; DELETE FROM weather WHERE city = 'Hayward';
</programlisting> </programlisting>
All weather recording belonging to Hayward are removed. All weather records belonging to Hayward are removed.
<programlisting> <programlisting>
SELECT * FROM weather; SELECT * FROM weather;
...@@ -779,10 +785,10 @@ SELECT * FROM weather; ...@@ -779,10 +785,10 @@ SELECT * FROM weather;
DELETE FROM <replaceable>tablename</replaceable>; DELETE FROM <replaceable>tablename</replaceable>;
</synopsis> </synopsis>
Without a qualification, <command>DELETE</command> will simply Without a qualification, <command>DELETE</command> will
remove all rows from the given table, leaving it remove <emphasis>all</> rows from the given table, leaving it
empty. The system will not request confirmation before empty. The system will not request confirmation before
doing this. doing this!
</para> </para>
</sect1> </sect1>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.17 2001/09/02 23:27:49 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.18 2001/11/19 05:37:53 tgl Exp $
--> -->
<chapter id="tutorial-start"> <chapter id="tutorial-start">
...@@ -104,8 +104,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.17 2001/09/02 23:27:49 peter ...@@ -104,8 +104,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/start.sgml,v 1.17 2001/09/02 23:27:49 peter
server can be on different hosts. In that case they communicate server can be on different hosts. In that case they communicate
over a TCP/IP network connection. You should keep this in mind, over a TCP/IP network connection. You should keep this in mind,
because the files that can be accessed on a client machine might because the files that can be accessed on a client machine might
not be accessible (or might only be accessed using a different not be accessible (or might only be accessible using a different
file name) on the database server machine. file path) on the database server machine.
</para> </para>
<para> <para>
...@@ -231,7 +231,7 @@ createdb: database creation failed ...@@ -231,7 +231,7 @@ createdb: database creation failed
You can also create databases with other names. You can also create databases with other names.
<productname>PostgreSQL</productname> allows you to create any <productname>PostgreSQL</productname> allows you to create any
number of databases at a given site. Database names must have an number of databases at a given site. Database names must have an
alphabetic first character and are limited to 32 characters in alphabetic first character and are limited to 31 characters in
length. A convenient choice is to create a database with the same length. A convenient choice is to create a database with the same
name as your current user name. Many tools assume that database name as your current user name. Many tools assume that database
name as the default, so it can save you some typing. To create name as the default, so it can save you some typing. To create
...@@ -372,9 +372,9 @@ mydb=# ...@@ -372,9 +372,9 @@ mydb=#
<para> <para>
The <command>psql</command> program has a number of internal The <command>psql</command> program has a number of internal
commands that are not SQL commands. They begin the backslash commands that are not SQL commands. They begin with the backslash
character, <quote><literal>\</literal></quote>. Some of these character, <quote><literal>\</literal></quote>. Some of these
commands were already listed in the welcome message. For example, commands were listed in the welcome message. For example,
you can get help on the syntax of various you can get help on the syntax of various
<productname>PostgreSQL</productname> <acronym>SQL</acronym> <productname>PostgreSQL</productname> <acronym>SQL</acronym>
commands by typing: commands by typing:
...@@ -396,7 +396,7 @@ mydb=# ...@@ -396,7 +396,7 @@ mydb=#
installed correctly you can also type <literal>man psql</literal> installed correctly you can also type <literal>man psql</literal>
at the operating system shell prompt to see the documentation. In at the operating system shell prompt to see the documentation. In
this tutorial we will not use these features explicitly, but you this tutorial we will not use these features explicitly, but you
can use them yourself when you see it fit. can use them yourself when you see fit.
</para> </para>
</sect1> </sect1>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment