11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.70 2001/11/1903:58:22 tgl Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.71 2001/11/1909:05:00 tgl Exp $
33-->
44
55 <chapter id="datatype">
@@ -23,15 +23,12 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.70 2001/11/19 03:58:22 tg
2323
2424 <para>
2525 <xref linkend="datatype-table"> shows all general-purpose data types
26- available to users. Most of the alternative names listed in the
26+ included in the standard distribution. Most of the alternative names
27+ listed in the
2728 <quote>Aliases</quote> column are the names used internally by
2829 <productname>Postgres</productname> for historical reasons. In
2930 addition, some internally used or deprecated types are available,
30- but they are not documented here. Many of the built-in types have
31- obvious external formats. However, several types are either unique
32- to <productname>Postgres</productname>, such as open and closed
33- paths, or have several possibilities for formats, such as the date
34- and time types.
31+ but they are not listed here.
3532 </para>
3633
3734 <para>
@@ -242,7 +239,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.70 2001/11/19 03:58:22 tg
242239 <row>
243240 <entry><type>timestamp [ with time zone ]</type></entry>
244241 <entry>timestamptz</entry>
245- <entry>date and time</entry>
242+ <entry>date and time, including time zone </entry>
246243 </row>
247244 </tbody>
248245 </tgroup>
@@ -264,22 +261,28 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.70 2001/11/19 03:58:22 tg
264261 </note>
265262
266263 <para>
264+ Each data type has an external representation determined by its input
265+ and output functions. Many of the built-in types have
266+ obvious external formats. However, several types are either unique
267+ to <productname>Postgres</productname>, such as open and closed
268+ paths, or have several possibilities for formats, such as the date
269+ and time types.
267270 Most of the input and output functions corresponding to the
268271 base types (e.g., integers and floating point numbers) do some
269272 error-checking.
273+ Some of the input and output functions are not invertible. That is,
274+ the result of an output function may lose precision when compared to
275+ the original input.
276+ </para>
277+
278+ <para>
270279 Some of the operators and functions (e.g.,
271280 addition and multiplication) do not perform run-time error-checking in the
272281 interests of improving execution speed.
273282 On some systems, for example, the numeric operators for some data types may
274283 silently underflow or overflow.
275284 </para>
276285
277- <para>
278- Some of the input and output functions are not invertible. That is,
279- the result of an output function may lose precision when compared to
280- the original input.
281- </para>
282-
283286 <sect1 id="datatype-numeric">
284287 <title>Numeric Types</title>
285288
@@ -465,6 +468,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.70 2001/11/19 03:58:22 tg
465468 platform where this is actually the case.
466469 </para>
467470
471+ <para>
472+ SQL only specifies the integer types <type>integer</type> (or
473+ <type>int</type>) and <type>smallint</type>. The type
474+ <type>bigint</type>, and the type names <type>int2</type>,
475+ <type>int4</type>, and <type>int8</type> are extensions, which
476+ are shared with various other RDBMS products.
477+ </para>
478+
468479 <note>
469480 <para>
470481 If you have a column of type <type>smallint</type> or
@@ -475,25 +486,17 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.70 2001/11/19 03:58:22 tg
475486... WHERE smallint_column = 42
476487</programlisting>
477488 will not use an index, because the system assigns type
478- <type>integer</type> to the 42, and PostgreSQL currently cannot
479- use an index when two different data types are involved. A
489+ <type>integer</type> to theconstant 42, and PostgreSQL currently
490+ cannot use an index when two different data types are involved. A
480491 workaround is to single-quote the constant, thus:
481492<programlisting>
482493... WHERE smallint_column = '42'
483494</programlisting>
484- This will cause the system to delaythe type resolution and will
495+ This will cause the system to delay type resolution and will
485496 assign the right type to the constant.
486497 </para>
487498 </note>
488499
489- <para>
490- SQL only specifies the integer types <type>integer</type> (or
491- <type>int</type>) and <type>smallint</type>. The type
492- <type>bigint</type>, and the type names <type>int2</type>,
493- <type>int4</type>, and <type>int8</type> are extensions, which
494- are shared with various other RDBMS products.
495- </para>
496-
497500 </sect2>
498501
499502 <sect2 id="datatype-numeric-decimal">
@@ -609,9 +612,9 @@ NUMERIC
609612
610613 <para>
611614 Normally, the <type>real</type> type has a range of at least
612- -1E+37 to +1E+37 with a precision of at least 6. The
615+ -1E+37 to +1E+37 with a precision of at least 6 decimal digits . The
613616 <type>double precision</type> type normally has a range of around
614- -1E+308 to +1E+308 with a precision of at least 15. Values that
617+ -1E+308 to +1E+308 with a precision of at least 15 digits . Values that
615618 are too large or too small will cause an error. Rounding may
616619 take place if the precision of an input number is too high.
617620 Numbers too close to zero that are not representable as distinct
@@ -1553,13 +1556,13 @@ January 8 04:05:06 1999 PST
15531556 or abbreviations or plurals of these units;
15541557 <literal>Direction</literal> can be <literal>ago</literal> or
15551558 empty. The at sign (<literal>@</>) is optional noise. The amounts
1556- of differentquantities are implicitly added up with appropriate
1559+ of differentunits are implicitly added up with appropriate
15571560 sign accounting.
15581561 </para>
15591562
15601563 <para>
15611564 Quantities of days, hours, minutes, and seconds can be specified without
1562- explicit unit markings: for example, <literal>'1 12:59:10'</> is read
1565+ explicit unit markings. For example, <literal>'1 12:59:10'</> is read
15631566 the same as <literal>'1 day 12 hours 59 min 10 sec'</>.
15641567 </para>
15651568 </sect3>
@@ -1637,10 +1640,6 @@ January 8 04:05:06 1999 PST
16371640 </tbody>
16381641 </tgroup>
16391642 </table>
1640- <literal>'now'</literal> is resolved when the value is inserted, <literal>'current'</literal>
1641- is resolved every time the value is retrieved. So you probably want to use <literal>'now'</literal>
1642- in most applications. (Of course you <emphasis>really</emphasis> want to use
1643- <literal>CURRENT_TIMESTAMP</literal>, which is equivalent to <literal>'now'</literal>.)
16441643 </para>
16451644 </sect3>
16461645
@@ -1705,7 +1704,7 @@ January 8 04:05:06 1999 PST
17051704 </para>
17061705
17071706 <para>
1708- The output of the <type>date</type> and <type>time</type>styles is of course
1707+ The output of the <type>date</type> and <type>time</type>types is of course
17091708 only the date or time part in accordance with the above examples.
17101709 </para>
17111710
@@ -1794,7 +1793,7 @@ January 8 04:05:06 1999 PST
17941793 <para>
17951794Although the <type>date</type> type
17961795does not have an associated time zone, the
1797- <type>time</type> type can or does .
1796+ <type>time</type> type can.
17981797Time zones in the real world can have no meaning unless
17991798associated with a date as well as a time
18001799since the offset may vary through the year with daylight savings