1- <!-- $Header: /cvsroot/pgsql/doc/src/sgml/ddl.sgml,v 1.5 2002/09/21 18:32:52 petere Exp $ -->
1+ <!-- $Header: /cvsroot/pgsql/doc/src/sgml/ddl.sgml,v 1.6 2002/10/20 05:05:46 tgl Exp $ -->
22
33<chapter id="ddl">
44 <title>Data Definition</title>
1010 explaining how tables are created and modified and what features are
1111 available to control what data is stored in the tables.
1212 Subsequently, we discuss how tables can be organized into
13- namespaces , and how privileges can be assigned to tables. Finally,
13+ schemas , and how privileges can be assigned to tables. Finally,
1414 we will briefly look at other features that affect the data storage,
1515 such as views, functions, and triggers. Detailed information on
1616 these topics is found in &cite-programmer;.
@@ -78,7 +78,7 @@ CREATE TABLE my_first_table (
7878 <literal>second_column</literal> and the type <type>integer</type>.
7979 The table and column names follow the identifier syntax explained
8080 in <xref linkend="sql-syntax-identifiers">. The type names are
81- also identifiers, but there are some exceptions. Note that the
81+ usually also identifiers, but there are some exceptions. Note that the
8282 column list is comma-separated and surrounded by parentheses.
8383 </para>
8484
@@ -101,7 +101,7 @@ CREATE TABLE products (
101101 <tip>
102102 <para>
103103 When you create many interrelated tables it is wise to choose a
104- consistent namingpatter for the tables and columns. For
104+ consistent namingpattern for the tables and columns. For
105105 instance, there is a choice of using singular or plural nouns for
106106 table names, both of which are favored by some theorist or other.
107107 </para>
@@ -287,7 +287,7 @@ CREATE TABLE products (
287287 </para>
288288
289289 <para>
290- The default value may be a scalar expression, whichwell be
290+ The default value may be a scalar expression, whichwill be
291291 evaluated whenever the default value is inserted
292292 (<emphasis>not</emphasis> when the table is created).
293293 </para>
@@ -618,7 +618,8 @@ CREATE TABLE example (
618618
619619 <para>
620620 A foreign key constraint specifies that the values in a column (or
621- a group of columns) must match the values in some other column.
621+ a group of columns) must match the values appearing in some row
622+ of another table.
622623 We say this maintains the <firstterm>referential
623624 integrity</firstterm> between two related tables.
624625 </para>
@@ -758,7 +759,7 @@ CREATE TABLE order_items (
758759 <para>
759760 Restricting and cascading deletes are the two most common options.
760761 <literal>RESTRICT</literal> can also be written as <literal>NO
761- ACTON </literal> and it's also the default if you don't specify
762+ ACTION </literal> and it's also the default if you don't specify
762763 anything. There are two other options for what should happen with
763764 the foreign key columns when a primary key is deleted:
764765 <literal>SET NULL</literal> and <literal>SET DEFAULT</literal>.
@@ -981,7 +982,7 @@ SET SQL_Inheritance TO OFF;
981982 <para>Add columns,</para>
982983 </listitem>
983984 <listitem>
984- <para>Removea column ,</para>
985+ <para>Removecolumns ,</para>
985986 </listitem>
986987 <listitem>
987988 <para>Add constraints,</para>
@@ -993,10 +994,10 @@ SET SQL_Inheritance TO OFF;
993994 <para>Change default values,</para>
994995 </listitem>
995996 <listitem>
996- <para>Renamea column ,</para>
997+ <para>Renamecolumns ,</para>
997998 </listitem>
998999 <listitem>
999- <para>Renamethe table .</para>
1000+ <para>Renametables .</para>
10001001 </listitem>
10011002 </itemizedlist>
10021003
@@ -1270,7 +1271,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
12701271 </itemizedlist>
12711272
12721273 Schemas are analogous to directories at the operating system level,
1273- but schemas cannot be nested.
1274+ except that schemas cannot be nested.
12741275 </para>
12751276
12761277 <sect2 id="ddl-schemas-create">
@@ -1341,7 +1342,7 @@ DROP SCHEMA myschema CASCADE;
13411342 (since this is one of the ways to restrict the activities of your
13421343 users to well-defined namespaces). The syntax for that is:
13431344<programlisting>
1344- CREATE SCHEMA <replaceable>schemaname</replaceable>AUTHORIZATON <replaceable>username</replaceable>;
1345+ CREATE SCHEMA <replaceable>schemaname</replaceable>AUTHORIZATION <replaceable>username</replaceable>;
13451346</programlisting>
13461347 You can even omit the schema name, in which case the schema name
13471348 will be the same as the user name. See <xref
@@ -1359,9 +1360,9 @@ CREATE SCHEMA <replaceable>schemaname</replaceable> AUTHORIZATON <replaceable>us
13591360
13601361 <para>
13611362 In the previous sections we created tables without specifying any
1362- schema names.Those tables (and other objects) are automatically
1363- put into a schema named <quote>public</quote>. Every new database
1364- contains such a schema. Thus, the following are equivalent:
1363+ schema names.By default, such tables (and other objects) are
1364+ automatically put into a schema named <quote>public</quote>. Every new
1365+ database contains such a schema. Thus, the following are equivalent:
13651366<programlisting>
13661367CREATE TABLE products ( ... );
13671368</programlisting>
@@ -1550,15 +1551,15 @@ REVOKE CREATE ON public FROM PUBLIC;
15501551
15511552 <para>
15521553 Schemas can be used to organize your data in many ways. There are
1553- a few usage patterns are recommended and are easily supported by
1554+ a few usage patternsthat are recommended and are easily supported by
15541555 the default configuration:
15551556 <itemizedlist>
15561557 <listitem>
15571558 <para>
15581559 If you do not create any schemas then all users access the
15591560 public schema implicitly. This simulates the situation where
15601561 schemas are not available at all. This setup is mainly
1561- recommended when there is only a single user or few cooperating
1562+ recommended when there is only a single user ora few cooperating
15621563 users in a database. This setup also allows smooth transition
15631564 from the non-schema-aware world.
15641565 </para>
@@ -1586,7 +1587,7 @@ REVOKE CREATE ON public FROM PUBLIC;
15861587 additional functions provided by third parties, etc.), put them
15871588 into separate schemas. Remember to grant appropriate
15881589 privileges to allow the other users to access them. Users can
1589- then refer to these additionalobject by qualifying the names
1590+ then refer to these additionalobjects by qualifying the names
15901591 with a schema name, or they can put the additional schemas into
15911592 their path, as they choose.
15921593 </para>
@@ -1690,9 +1691,10 @@ ERROR: Cannot drop table products because other objects depend on it
16901691<screen>
16911692DROP TABLE products CASCADE;
16921693</screen>
1693- and all the dependent objects will be removed.Actually, this
1694+ and all the dependent objects will be removed.In this case, it
16941695 doesn't remove the orders table, it only removes the foreign key
1695- constraint.
1696+ constraint. (If you want to check what DROP ... CASCADE will do,
1697+ run DROP without CASCADE and read the NOTICEs.)
16961698 </para>
16971699
16981700 <para>
@@ -1709,7 +1711,8 @@ DROP TABLE products CASCADE;
17091711 According to the SQL standard, specifying either
17101712 <literal>RESTRICT</literal> or <literal>CASCADE</literal> is
17111713 required. No database system actually implements it that way, but
1712- the defaults might be different.
1714+ whether the default behavior is <literal>RESTRICT</literal> or
1715+ <literal>CASCADE</literal> varies across systems.
17131716 </para>
17141717 </note>
17151718
@@ -1718,7 +1721,8 @@ DROP TABLE products CASCADE;
17181721 Foreign key constraint dependencies and serial column dependencies
17191722 from <productname>PostgreSQL</productname> versions prior to 7.3
17201723 are <emphasis>not</emphasis> maintained or created during the
1721- upgrade process. All other dependency types survive the upgrade.
1724+ upgrade process. All other dependency types will be properly
1725+ created during an upgrade.
17221726 </para>
17231727 </note>
17241728 </sect1>