From d42d31e78e2f9db73edb0b0ed35cafb1c409bdbf Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 14 Feb 2001 19:37:26 +0000 Subject: [PATCH] Alter documentation of boolean type, add example. Someone figured that it wasn't clear that the "boolean type" was actually called "boolean". Add tip about "casting" booleans using CASE. Spell check whole file. --- doc/src/sgml/datatype.sgml | 192 ++++++++++++++++++++----------------- 1 file changed, 105 insertions(+), 87 deletions(-) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 10d6304cc1..22615a0868 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,5 +1,5 @@ @@ -27,8 +27,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.49 2001/02/10 18:02:35 pe - <productname>Postgres</productname> Data Types - Data Types + Data Types @@ -60,7 +59,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.49 2001/02/10 18:02:35 pe boolean bool - logical boolean (true/false) + logical Boolean (true/false) @@ -265,12 +264,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.49 2001/02/10 18:02:35 pe
- <productname>Postgres</productname> Numeric Types - Numerics + Numeric Types - Numeric Type + Type Name Storage Description Range @@ -326,7 +324,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.49 2001/02/10 18:02:35 pe serial 4 bytes - Identifer or cross-reference + Identifier or cross-reference 0 to +2147483647 @@ -424,12 +422,11 @@ CREATE TABLE tablename (
- <productname>Postgres</productname> Monetary Types - Money + Monetary Types - Monetary Type + Type Name Storage Description Range @@ -470,12 +467,11 @@ CREATE TABLE tablename (
- <productname>Postgres</productname> Character Types - Characters + Character Types - Character Type + Type Name Storage Recommendation Description @@ -530,12 +526,11 @@ CREATE TABLE tablename (
- <productname>Postgres</productname> Specialty Character Type - Specialty Characters + Specialty Character Type - Character Type + Type Name Storage Description @@ -568,8 +563,7 @@ CREATE TABLE tablename (
- <productname>Postgres</productname> Date/Time Types - Date/Time + Date/Time Types @@ -588,7 +582,7 @@ CREATE TABLE tablename (8 bytes 4713 BC AD 1465001 - 1 microsec / 14 digits + 1 microsecond / 14 digits timestamp [ with time zone ] @@ -596,7 +590,7 @@ CREATE TABLE tablename (8 bytes 1903 AD 2037 AD - 1 microsec / 14 digits + 1 microsecond / 14 digits interval @@ -690,8 +684,7 @@ CREATE TABLE tablename (date type.
- <productname>Postgres</productname> Date Input - Date Inputs + Date Input @@ -747,8 +740,7 @@ CREATE TABLE tablename (
- <productname>Postgres</productname> Month Abbreviations - Month Abbreviations + Month Abbreviations @@ -814,8 +806,7 @@ CREATE TABLE tablename (
- <productname>Postgres</productname> Day of Week Abbreviations - Day of Week Abbreviations + Day of the Week Abbreviations @@ -870,8 +861,7 @@ CREATE TABLE tablename (time inputs.
- <productname>Postgres</productname> Time Input - Time Inputs + Time Input @@ -940,9 +930,7 @@ CREATE TABLE tablename ( - <productname>Postgres</productname> Time With Time - Zone Input - Time With Time Zone Inputs + Time With Time Zone Input @@ -1002,8 +990,7 @@ January 8 04:05:06 1999 PST
- <productname>Postgres</productname> Time Zone Input - Time Zone Inputs + Time Zone Input @@ -1062,7 +1049,7 @@ January 8 04:05:06 1999 PST The following SQL-compatible functions can be used as date or time - input for the corresponding datatype: CURRENT_DATE, + input for the corresponding data type: CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP. @@ -1070,8 +1057,7 @@ January 8 04:05:06 1999 PST convenience.
- <productname>Postgres</productname> Special Date/Time Constants - Constants + Special Date/Time Constants @@ -1120,7 +1106,7 @@ January 8 04:05:06 1999 PST
'now' is resolved when the value is inserted, 'current' - is resolved everytime the value is retrieved. So you probably want to use 'now' + is resolved every time the value is retrieved. So you probably want to use 'now' in most applications. (Of course you really want to use CURRENT_TIMESTAMP, which is equivalent to 'now'.)
@@ -1139,8 +1125,7 @@ January 8 04:05:06 1999 PST The default is the ISO format. - <productname>Postgres</productname> Date/Time Output Styles - Styles + Date/Time Output Styles @@ -1182,12 +1167,11 @@ January 8 04:05:06 1999 PST The SQL style has European and non-European (US) variants, - which determines whether month follows day or vica versa. (See also above + which determines whether month follows day or vice versa. (See also above at Date/Time Input, how this setting affects interpretation of input values.)
- <productname>Postgres</productname> Date Order Conventions - Date Order + Date Order Conventions @@ -1360,7 +1344,7 @@ January 8 04:05:06 1999 PST If the compiler option USE_AUSTRALIAN_RULES is set - then EST refers to Australia Eastern Std Time, + then EST refers to Australia Eastern Standard Time, which has an offset of +10:00 hours from UTC. @@ -1381,7 +1365,7 @@ January 8 04:05:06 1999 PST Date conventions before the 19th century make for interesting reading, - but are not consistant enough to warrant coding into a date/time handler. + but are not consistent enough to warrant coding into a date/time handler. @@ -1391,46 +1375,81 @@ January 8 04:05:06 1999 PST Boolean Type - Postgres supports the - SQL99 boolean type. - boolean can have one of only two states: 'true' or - 'false'. A third state, 'unknown', is represented by the SQL NULL - state. boolean can be used in any boolean expression, - and boolean expressions always evaluate to a result compatible - with this type. + Postgres provides the + SQL99 type boolean. + boolean can have one of only two states: + true or false. A third state, + unknown, is represented by the + SQL NULL state. + + Valid literal values for the true state are: + + TRUE + 't' + 'true' + 'y' + 'yes' + '1' + + For the false state, the following values can be + used: + + FALSE + 'f' + 'false' + 'n' + 'no' + '0' + + Using the key words TRUE and + FALSE is preferred (and + SQL-compliant). + + + + Using the <type>boolean</type> type + + +CREATE TABLE test1 (a boolean, b text); +INSERT INTO test1 VALUES (TRUE, 'sic est'); +INSERT INTO test1 VALUES (FALSE, 'non est'); +SELECT * FROM test1; + a | b +---+--------- + t | sic est + f | non est + +SELECT * FROM test1 WHERE a; + a | b +---+--------- + t | sic est + + + + + shows that + boolean values are output using the letters + t and f. + + + + + Values of the boolean type cannot be cast directly + to other types (e.g., CAST + (boolval AS integer) does + not work). This can be accomplished using the + CASE expression: CASE WHEN + boolval THEN 'value if true' ELSE + 'value if false' END. See also . + + + boolean uses 1 byte of storage. - - -
- <productname>Postgres</productname> Boolean Type - Booleans - - - - State - Input - Output - - - - - True - TRUE, 't', 'true', 'y', 'yes', '1' - t - - - False - FALSE, 'f', 'false', 'n', 'no', '0' - f - - - -
- @@ -1444,8 +1463,7 @@ January 8 04:05:06 1999 PST - <productname>Postgres</productname> Geometric Types - Geometrics + Geometric Types @@ -1578,7 +1596,7 @@ January 8 04:05:06 1999 PST (x2,y2) - The endpoints of the line segment. + The end points of the line segment. @@ -1662,7 +1680,7 @@ January 8 04:05:06 1999 PST (x,y) - Endpoints of the line segments comprising the path. + End points of the line segments comprising the path. A leading square bracket ("[") indicates an open path, while a leading parenthesis ("(") indicates a closed path. @@ -1702,7 +1720,7 @@ January 8 04:05:06 1999 PST (x,y) - Endpoints of the line segments comprising the boundary of the + End points of the line segments comprising the boundary of the polygon. @@ -1822,7 +1840,7 @@ January 8 04:05:06 1999 PST The inet type holds an IP host address, and optionally the identity of the subnet it is in, all in one field. The subnet identity is represented by the number of bits in the - network part of the address (the "netmask"). If the netmask is 32, + network part of the address (the netmask). If the netmask is 32, then the value does not indicate a subnet, only a single host. Note that if you want to accept networks only, you should use the cidr type rather than inet. @@ -1989,7 +2007,7 @@ January 8 04:05:06 1999 PST x specifies the maximum length. BIT type data is automatically padded with 0's on the right to the maximum length, BIT VARYING is of - variable length. BIT without length is requivalent + variable length. BIT without length is equivalent to BIT(1), BIT VARYING means unlimited length. Input data that is longer than the allowed length will be truncated. Refer to