Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited19393

Browse files
committed
Some marginal editorial improvements and updates in the tutorial.
1 parent9c2c416 commited19393

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

‎doc/src/sgml/advanced.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/advanced.sgml,v 1.51 2006/09/16 00:30:11 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/advanced.sgml,v 1.52 2006/10/21 23:12:57 tgl Exp $ -->
22

33
<chapter id="tutorial-advanced">
44
<title>Advanced Features</title>
@@ -384,7 +384,7 @@ CREATE TABLE capitals (
384384
type of the column <structfield>name</structfield> is
385385
<type>text</type>, a native <productname>PostgreSQL</productname>
386386
type for variable length character strings. State capitals have
387-
an extra column, state, that shows their state. In
387+
an extra column,<structfield>state</>, that shows their state. In
388388
<productname>PostgreSQL</productname>, a table can inherit from
389389
zero or more other tables.
390390
</para>

‎doc/src/sgml/query.sgml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.47 2006/09/16 00:30:15 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.48 2006/10/21 23:12:57 tgl Exp $ -->
22

33
<chapter id="tutorial-sql">
44
<title>The <acronym>SQL</acronym> Language</title>
@@ -20,7 +20,7 @@
2020
<para>
2121
In the examples that follow, we assume that you have created a
2222
database named <literal>mydb</literal>, as described in the previous
23-
chapter, and havestarted <application>psql</application>.
23+
chapter, and havebeen able to start <application>psql</application>.
2424
</para>
2525

2626
<para>
@@ -35,12 +35,15 @@
3535
</screen>
3636

3737
This creates the scripts and compiles the C files containing user-defined
38-
functions and types. (You must use GNU make for this &mdash; it may be named
39-
something different on your system, often <application>gmake</>.)
38+
functions and types. (If you installed a pre-packaged version of
39+
<productname>PostgreSQL</productname> rather than building from source,
40+
look for a directory named <filename>tutorial</> within the
41+
<productname>PostgreSQL</productname> documentation. The <quote>make</>
42+
part should already have been done for you.)
4043
Then, to start the tutorial, do the following:
4144

4245
<screen>
43-
<prompt>$</prompt> <userinput>cd <replaceable>....</replaceable>/src/tutorial</userinput>
46+
<prompt>$</prompt> <userinput>cd <replaceable>....</replaceable>/tutorial</userinput>
4447
<prompt>$</prompt> <userinput>psql -s mydb</userinput>
4548
<computeroutput>
4649
...
@@ -416,7 +419,7 @@ SELECT DISTINCT city
416419
In some database systems, including older versions of
417420
<productname>PostgreSQL</productname>, the implementation of
418421
<literal>DISTINCT</literal> automatically orders the rows and
419-
so <literal>ORDER BY</literal> isredundant. But this is not
422+
so <literal>ORDER BY</literal> isunnecessary. But this is not
420423
required by the SQL standard, and current
421424
<productname>PostgreSQL</productname> doesn't guarantee that
422425
<literal>DISTINCT</literal> causes the rows to be ordered.
@@ -518,15 +521,21 @@ SELECT city, temp_lo, temp_hi, prcp, date, location
518521

519522
<para>
520523
Since the columns all had different names, the parser
521-
automatically found out which table they belong to, but it is good
522-
style to fully qualify column names in join queries:
524+
automatically found out which table they belong to. If there
525+
were duplicate column names in the two tables you'd need to
526+
<firstterm>qualify</> the column names to show which one you
527+
meant, as in:
523528

524529
<programlisting>
525530
SELECT weather.city, weather.temp_lo, weather.temp_hi,
526531
weather.prcp, weather.date, cities.location
527532
FROM weather, cities
528533
WHERE cities.name = weather.city;
529534
</programlisting>
535+
536+
It is widely considered good style to qualify all column names
537+
in a join query, so that the query won't fail if a duplicate
538+
column name is later added to one of the tables.
530539
</para>
531540

532541
<para>
@@ -548,7 +557,7 @@ SELECT *
548557
Now we will figure out how we can get the Hayward records back in.
549558
What we want the query to do is to scan the
550559
<classname>weather</classname> table and for each row to find the
551-
matching <classname>cities</classname> row. If no matching row is
560+
matching <classname>cities</classname> row(s). If no matching row is
552561
found we want some <quote>empty values</quote> to be substituted
553562
for the <classname>cities</classname> table's columns. This kind
554563
of query is called an <firstterm>outer join</firstterm>. (The
@@ -681,11 +690,11 @@ SELECT city FROM weather WHERE temp_lo = max(temp_lo); <lineannotation>WRONG
681690
but this will not work since the aggregate
682691
<function>max</function> cannot be used in the
683692
<literal>WHERE</literal> clause. (This restriction exists because
684-
the <literal>WHERE</literal> clause determinesthe rowsthatwill
685-
go into theaggregation stage; so it has to be evaluated before
686-
aggregate functions are computed.)
693+
the <literal>WHERE</literal> clause determineswhich rows will be
694+
included in theaggregate calculation; soobviouslyit has to be evaluated
695+
beforeaggregate functions are computed.)
687696
However, as is often the case
688-
the query can be restated to accomplish theintended result, here
697+
the query can be restated to accomplish thedesired result, here
689698
by using a <firstterm>subquery</firstterm>:
690699

691700
<programlisting>
@@ -808,7 +817,7 @@ SELECT city, max(temp_lo)
808817
You can update existing rows using the
809818
<command>UPDATE</command> command.
810819
Suppose you discover the temperature readings are
811-
alloffby 2 degreesas ofNovember 28. You mayupdate the
820+
all off by 2 degreesafterNovember 28. You maycorrect the
812821
data as follows:
813822

814823
<programlisting>

‎doc/src/sgml/start.sgml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/start.sgml,v 1.42 2006/09/16 00:30:15 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/start.sgml,v 1.43 2006/10/21 23:12:57 tgl Exp $ -->
22

33
<chapter id="tutorial-start">
44
<title>Getting Started</title>
@@ -181,8 +181,7 @@ createdb: command not found
181181
<para>
182182
Another response could be this:
183183
<screen>
184-
createdb: could not connect to database postgres: could not connect to server:
185-
No such file or directory
184+
createdb: could not connect to database postgres: could not connect to server: No such file or directory
186185
Is the server running locally and accepting
187186
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
188187
</screen>
@@ -194,8 +193,7 @@ No such file or directory
194193
<para>
195194
Another response could be this:
196195
<screen>
197-
createdb: could not connect to database postgres: FATAL: user "joe" does not
198-
exist
196+
createdb: could not connect to database postgres: FATAL: role "joe" does not exist
199197
</screen>
200198
where your own login name is mentioned. This will happen if the
201199
administrator has not created a <productname>PostgreSQL</> user account
@@ -229,7 +227,7 @@ createdb: database creation failed: ERROR: permission denied to create database
229227
<para>
230228
As an explanation for why this works:
231229
<productname>PostgreSQL</productname> user names are separate
232-
from operating system user accounts.If you connect to a
230+
from operating system user accounts.When you connect to a
233231
database, you can choose what
234232
<productname>PostgreSQL</productname> user name to connect as;
235233
if you don't, it will default to the same name as your current
@@ -353,7 +351,7 @@ mydb=#
353351
That would mean you are a database superuser, which is most likely
354352
the case if you installed <productname>PostgreSQL</productname>
355353
yourself. Being a superuser means that you are not subject to
356-
access controls. For thepurpose of this tutorialthis is not of
354+
access controls. For thepurposes of this tutorialthat is not of
357355
importance.
358356
</para>
359357

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp