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

Commit5ae3816

Browse files
author
Neil Conway
committed
Improve discussion of using OIDs for identifying rows, fix an instance of
incorrect SGML markup.
1 parent6a1e2b3 commit5ae3816

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

‎doc/src/sgml/ddl.sgml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.25 2003/11/29 19:51:36 pgsql Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.26 2004/03/07 04:31:01 neilc Exp $ -->
22

33
<chapter id="ddl">
44
<title>Data Definition</title>
@@ -77,8 +77,8 @@
7777
</indexterm>
7878

7979
<para>
80-
To create a table, you use the aptly named <literal>CREATE
81-
TABLE</literal> command. In this command you specify at least a
80+
To create a table, you use the aptly named <command>CREATE
81+
TABLE</command> command. In this command you specify at least a
8282
name for the new table, the names of the columns and the data type
8383
of each column. For example:
8484
<programlisting>
@@ -302,18 +302,38 @@ DROP TABLE products;
302302
</variablelist>
303303

304304
<para>
305-
OIDs are 32-bit quantities and are assigned from a single cluster-wide
306-
counter. In a large or long-lived database, it is possible for the
307-
counter to wrap around. Hence, it is bad practice to assume that OIDs
308-
are unique, unless you take steps to ensure that they are unique.
309-
Recommended practice when using OIDs for row identification is to create
310-
a unique constraint on the OID column of each table for which the OID will
311-
be used. Never assume that OIDs are unique across tables; use the
312-
combination of <structfield>tableoid</> and row OID if you need a
313-
database-wide identifier. (Future releases of
314-
<productname>PostgreSQL</productname> are likely to use a separate
315-
OID counter for each table, so that <structfield>tableoid</>
316-
<emphasis>must</> be included to arrive at a globally unique identifier.)
305+
OIDs are 32-bit quantities and are assigned from a single
306+
cluster-wide counter. In a large or long-lived database, it is
307+
possible for the counter to wrap around. Hence, it is bad
308+
practice to assume that OIDs are unique, unless you take steps to
309+
ensure that this is the case. If you need to identify the rows in
310+
a table, using a sequence generator is strongly recommended.
311+
However, OIDs can be used as well, provided that a few additional
312+
precautions are taken:
313+
314+
<itemizedlist>
315+
<listitem>
316+
<para>
317+
A unique constraint should be created on the OID column of each
318+
table for which the OID will be used to identify rows.
319+
</para>
320+
</listitem>
321+
<listitem>
322+
<para>
323+
OIDs should never be assumed to be unique across tables; use
324+
the combination of <structfield>tableoid</> and row OID if you
325+
need a database-wide identifier.
326+
</para>
327+
</listitem>
328+
<listitem>
329+
<para>
330+
The tables in question should be created using <literal>WITH
331+
OIDS</literal> to ensure forward compatibility with future
332+
releases of <productname>PostgreSQL</productname> in which OIDs
333+
are not included in all tables by default.
334+
</para>
335+
</listitem>
336+
</itemizedlist>
317337
</para>
318338

319339
<para>
@@ -798,7 +818,7 @@ CREATE TABLE orders (
798818
);
799819
</programlisting>
800820
Now it is impossible to create orders with
801-
<literal>product_no</literal> entries that do not appear in the
821+
<structfield>product_no</structfield> entries that do not appear in the
802822
products table.
803823
</para>
804824

@@ -892,7 +912,7 @@ CREATE TABLE order_items (
892912

893913
<para>
894914
To illustrate this, let's implement the following policy on the
895-
many-to-many relationship example above:When someone wants to
915+
many-to-many relationship example above:when someone wants to
896916
remove a product that is still referenced by an order (via
897917
<literal>order_items</literal>), we disallow it. If someone
898918
removes an order, the order items are removed as well.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp