|
1 | | -<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ddl.sgml,v 1.22 2003/11/04 09:55:38 petere Exp $ --> |
| 1 | +<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ddl.sgml,v 1.23 2003/11/05 00:05:32 tgl Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="ddl"> |
4 | 4 | <title>Data Definition</title> |
|
12 | 12 | Subsequently, we discuss how tables can be organized into |
13 | 13 | schemas, and how privileges can be assigned to tables. Finally, |
14 | 14 | we will briefly look at other features that affect the data storage, |
15 | | - such as views, functions, and triggers. Detailed information on |
16 | | - these topics is found in <xref linkend="server-programming">. |
| 15 | + such as views, functions, and triggers. |
17 | 16 | </para> |
18 | 17 |
|
19 | 18 | <sect1 id="ddl-basics"> |
@@ -522,7 +521,7 @@ CREATE TABLE products ( |
522 | 521 | <para> |
523 | 522 | It should be noted that a check constraint is satisfied if the |
524 | 523 | check expression evaluates to true or the null value. Since most |
525 | | - expressions will evaluate to the null value if one operand is null |
| 524 | + expressions will evaluate to the null value if one operand is null, |
526 | 525 | they will not prevent null values in the constrained columns. To |
527 | 526 | ensure that a column does not contain null values, the not-null |
528 | 527 | constraint described in the next section should be used. |
@@ -586,7 +585,7 @@ CREATE TABLE products ( |
586 | 585 | The <literal>NULL</literal> constraint is not defined in the SQL |
587 | 586 | standard and should not be used in portable applications. (It was |
588 | 587 | only added to <productname>PostgreSQL</productname> to be |
589 | | - compatible with other database systems.) Some users, however, |
| 588 | + compatible withsomeother database systems.) Some users, however, |
590 | 589 | like it because it makes it easy to toggle the constraint in a |
591 | 590 | script file. For example, you could start with |
592 | 591 | <programlisting> |
@@ -820,7 +819,7 @@ CREATE TABLE orders ( |
820 | 819 | ); |
821 | 820 | </programlisting> |
822 | 821 | because in absence of a column list the primary key of the |
823 | | - referenced table is used as referenced column. |
| 822 | + referenced table is used asthereferenced column. |
824 | 823 | </para> |
825 | 824 |
|
826 | 825 | <para> |
@@ -1094,9 +1093,10 @@ WHERE c.altitude > 500 and c.tableoid = p.oid; |
1094 | 1093 | <title>Deprecated</title> |
1095 | 1094 | <para> |
1096 | 1095 | In previous versions of <productname>PostgreSQL</productname>, the |
1097 | | - default was not to get access to child tables. This was found to |
1098 | | - be error prone and is also in violation of the SQL99 standard. Under the old |
1099 | | - syntax, to get the sub-tables you append <literal>*</literal> to the table name. |
| 1096 | + default behavior was not to include child tables in queries. This was |
| 1097 | + found to be error prone and is also in violation of the SQL99 |
| 1098 | + standard. Under the old syntax, to get the sub-tables you append |
| 1099 | + <literal>*</literal> to the table name. |
1100 | 1100 | For example |
1101 | 1101 | <programlisting> |
1102 | 1102 | SELECT * from cities*; |
@@ -1270,6 +1270,12 @@ ALTER TABLE products ALTER COLUMN product_no SET NOT NULL; |
1270 | 1270 | <programlisting> |
1271 | 1271 | ALTER TABLE products DROP CONSTRAINT some_name; |
1272 | 1272 | </programlisting> |
| 1273 | + (If you are dealing with a generated constraint name like <literal>$2</>, |
| 1274 | + don't forget that you'll need to double-quote it to make it a valid |
| 1275 | + identifier.) |
| 1276 | + </para> |
| 1277 | + |
| 1278 | + <para> |
1273 | 1279 | This works the same for all constraint types except not-null |
1274 | 1280 | constraints. To drop a not null constraint use |
1275 | 1281 | <programlisting> |
@@ -1739,9 +1745,11 @@ SELECT 3 OPERATOR(pg_catalog.+) 4; |
1739 | 1745 | A user can also be allowed to create objects in someone else's |
1740 | 1746 | schema. To allow that, the <literal>CREATE</literal> privilege on |
1741 | 1747 | the schema needs to be granted. Note that by default, everyone |
1742 | | - has the <literal>CREATE</literal> privilege on the schema |
1743 | | - <literal>public</literal>. This allows all users that manage to |
1744 | | - connect to a given database to create objects there. If you do |
| 1748 | + has <literal>CREATE</literal> and <literal>USAGE</literal> privileges on |
| 1749 | + the schema |
| 1750 | + <literal>public</literal>. This allows all users that are able to |
| 1751 | + connect to a given database to create objects in its |
| 1752 | + <literal>public</literal> schema. If you do |
1745 | 1753 | not want to allow that, you can revoke that privilege: |
1746 | 1754 | <programlisting> |
1747 | 1755 | REVOKE CREATE ON SCHEMA public FROM PUBLIC; |
@@ -1905,6 +1913,11 @@ REVOKE CREATE ON SCHEMA public FROM PUBLIC; |
1905 | 1913 | </para> |
1906 | 1914 | </listitem> |
1907 | 1915 | </itemizedlist> |
| 1916 | + |
| 1917 | + <para> |
| 1918 | + Detailed information on |
| 1919 | + these topics appears in <xref linkend="server-programming">. |
| 1920 | + </para> |
1908 | 1921 | </sect1> |
1909 | 1922 |
|
1910 | 1923 | <sect1 id="ddl-depend"> |
|