Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
526427f6
Commit
526427f6
authored
Jan 13, 2001
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add information about bit types. Adjust some other things to promote
SQL type names over internal type names.
parent
475c1452
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
356 additions
and
264 deletions
+356
-264
doc/src/sgml/datatype.sgml
doc/src/sgml/datatype.sgml
+259
-228
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+95
-34
doc/src/sgml/syntax.sgml
doc/src/sgml/syntax.sgml
+2
-2
No files found.
doc/src/sgml/datatype.sgml
View file @
526427f6
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.4
6 2000/12/22 18:57:49
petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.4
7 2001/01/13 18:34:51
petere Exp $
-->
-->
<chapter id="datatype">
<chapter id="datatype">
<title id="datatype-title">Data Types</title>
<title id="datatype-title">Data Types</title>
<abstract>
<para>
Describes the built-in data types available in
<productname>Postgres</productname>.
</para>
</abstract>
<para>
<para>
<productname>Postgres</productname> has a rich set of native data
<productname>Postgres</productname> has a rich set of native data
types available to users.
types available to users.
...
@@ -20,229 +13,229 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
...
@@ -20,229 +13,229 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
</para>
</para>
<para>
<para>
In the context of data types, the following sections will discuss
<xref linkend="datatype-table"> shows all general-purpose data types
<acronym>SQL</acronym> standards compliance, porting issues, and usage.
available to users. Most of the alternative names listed in the
<quote>Aliases</quote> column are the names used internally by
Some <productname>Postgres</productname> types correspond directly to
<productname>Postgres</productname> for historical reasons. In
<acronym>SQL92</acronym>-compatible types. In other
addition, some internally used or deprecated types are available,
cases, data types defined by <acronym>SQL92</acronym> syntax are mapped directly
but they are not documented here. Many of the built-in types have
into native <productname>Postgres</productname> types.
obvious external formats. However, several types are either unique
to <productname>Postgres</productname>, such as open and closed
Many of the built-in types have obvious external formats. However, several
paths, or have several possibilities for formats, such as the date
types are either unique to <productname>Postgres</productname>,
and time types.
such as open and closed paths, or have
several possibilities for formats, such as the date and time types.
</para>
</para>
<para>
<para>
<table
tocentry="1
">
<table
id="datatype-table
">
<title><productname>Postgres</productname> Data Types</title>
<title><productname>Postgres</productname> Data Types</title>
<titleabbrev>Data Types</titleabbrev>
<titleabbrev>Data Types</titleabbrev>
<tgroup cols="3">
<tgroup cols="3">
<thead>
<thead>
<row>
<row>
<entry>
<productname>Postgres</productname> Typ
e</entry>
<entry>
Type Nam
e</entry>
<entry>
<acronym>SQL92</acronym> or <acronym>SQL99</acronym> Type
</entry>
<entry>
Aliases
</entry>
<entry>Description</entry>
<entry>Description</entry>
</row>
</row>
</thead>
</thead>
<tbody>
<tbody>
<row>
<row>
<entry>
bool
</entry>
<entry>
<type>bigint</type>
</entry>
<entry>
boolean
</entry>
<entry>
<type>int8</type>
</entry>
<entry>
logical boolean (true/false)
</entry>
<entry>
signed eight-byte integer
</entry>
</row>
</row>
<row>
<row>
<entry>
box
</entry>
<entry>
<type>bit</type>
</entry>
<entry></entry>
<entry></entry>
<entry>
rectangular box in 2D plane
</entry>
<entry>
fixed-length bit string
</entry>
</row>
</row>
<row>
<row>
<entry>
char(n)
</entry>
<entry>
<type>bit varying(<replaceable>n</replaceable>)</type>
</entry>
<entry>
character(n)
</entry>
<entry>
<type>varbit(<replaceable>n</replaceable>)</type>
</entry>
<entry>
fixed-length character
string</entry>
<entry>
variable-length bit
string</entry>
</row>
</row>
<row>
<row>
<entry>
cidr
</entry>
<entry>
<type>boolean</type>
</entry>
<entry></entry>
<entry><
type>bool</type><
/entry>
<entry>
IP network address
</entry>
<entry>
logical boolean (true/false)
</entry>
</row>
</row>
<row>
<row>
<entry>
circle
</entry>
<entry>
<type>box</type>
</entry>
<entry></entry>
<entry></entry>
<entry>
circle
in 2D plane</entry>
<entry>
rectangular box
in 2D plane</entry>
</row>
</row>
<row>
<row>
<entry>
date
</entry>
<entry>
<type>character(<replaceable>n</replaceable>)</type>
</entry>
<entry>
date
</entry>
<entry>
<type>char(<replaceable>n</replaceable>)</type>
</entry>
<entry>
calendar date without time of day
</entry>
<entry>
fixed-length character string
</entry>
</row>
</row>
<row>
<row>
<entry>
decimal
</entry>
<entry>
<type>character varying(<replaceable>n</replaceable>)</type>
</entry>
<entry>
decimal(p,s)
</entry>
<entry>
<type>varchar(<replaceable>n</replaceable>)</type>
</entry>
<entry>
exact numeric with selectable precision
</entry>
<entry>
variable-length character string
</entry>
</row>
</row>
<row>
<row>
<entry>
float4
</entry>
<entry>
<type>cidr</type>
</entry>
<entry>
float(<replaceable>p</replaceable>), <replaceable>p</replaceable> < 7
</entry>
<entry></entry>
<entry>
floating-point number with precision <replaceable>p</replaceable>
</entry>
<entry>
IP network address
</entry>
</row>
</row>
<row>
<row>
<entry>
float8
</entry>
<entry>
<type>circle</type>
</entry>
<entry>
float(<replaceable>p</replaceable>), 7 <= <replaceable>p</replaceable> < 16
</entry>
<entry></entry>
<entry>
floating-point number with precision <replaceable>p</replaceable>
</entry>
<entry>
circle in 2D plane
</entry>
</row>
</row>
<row>
<row>
<entry>
inet
</entry>
<entry>
<type>date</type>
</entry>
<entry></entry>
<entry></entry>
<entry>
IP network or host address
</entry>
<entry>
calendar date (year, month, day)
</entry>
</row>
</row>
<row>
<row>
<entry>
int2
</entry>
<entry>
<type>double precision</type>
</entry>
<entry>
smallint
</entry>
<entry>
<type>float8</type>
</entry>
<entry>
signed two-byte integ
er</entry>
<entry>
double precision floating-point numb
er</entry>
</row>
</row>
<row>
<row>
<entry>
int4
</entry>
<entry>
<type>inet</type>
</entry>
<entry>
int, integer
</entry>
<entry></entry>
<entry>
signed 4-byte integer
</entry>
<entry>
IP host address
</entry>
</row>
</row>
<row>
<row>
<entry>
int8
</entry>
<entry>
<type>integer</type>
</entry>
<entry></entry>
<entry><
type>int</type>, <type>int4</type><
/entry>
<entry>signed
8
-byte integer</entry>
<entry>signed
four
-byte integer</entry>
</row>
</row>
<row>
<row>
<entry>
interval
</entry>
<entry>
<type>interval</type>
</entry>
<entry>
interval
</entry>
<entry></entry>
<entry>general-use time span</entry>
<entry>general-use time span</entry>
</row>
</row>
<row>
<row>
<entry>
line
</entry>
<entry>
<type>line</type>
</entry>
<entry></entry>
<entry></entry>
<entry>infinite line in 2D plane</entry>
<entry>infinite line in 2D plane</entry>
</row>
</row>
<row>
<row>
<entry>
lseg
</entry>
<entry>
<type>lseg</type>
</entry>
<entry></entry>
<entry></entry>
<entry>line segment in 2D plane</entry>
<entry>line segment in 2D plane</entry>
</row>
</row>
<row>
<row>
<entry>money</entry>
<entry><type>macaddr</type></entry>
<entry>decimal(9,2)</entry>
<entry></entry>
<entry>MAC address</entry>
</row>
<row>
<entry><type>money</type></entry>
<entry></entry>
<entry>US-style currency</entry>
<entry>US-style currency</entry>
</row>
</row>
<row>
<row>
<entry>
numeric
</entry>
<entry>
<type>numeric(<replaceable>p</replaceable>, <replaceable>s</replaceable>)</type>
</entry>
<entry>
numeric(p,s)
</entry>
<entry>
<type>decimal(<replaceable>p</replaceable>, <replaceable>s</replaceable>)</type>
</entry>
<entry>exact numeric with selectable precision</entry>
<entry>exact numeric with selectable precision</entry>
</row>
</row>
<row>
<row>
<entry>path</entry>
<entry><type>oid</type></entry>
<entry></entry>
<entry>object identifier</entry>
</row>
<row>
<entry><type>path</type></entry>
<entry></entry>
<entry></entry>
<entry>open and closed geometric path in 2D plane</entry>
<entry>open and closed geometric path in 2D plane</entry>
</row>
</row>
<row>
<row>
<entry>
point
</entry>
<entry>
<type>point</type>
</entry>
<entry></entry>
<entry></entry>
<entry>geometric point in 2D plane</entry>
<entry>geometric point in 2D plane</entry>
</row>
</row>
<row>
<row>
<entry>
polygon
</entry>
<entry>
<type>polygon</type>
</entry>
<entry></entry>
<entry></entry>
<entry>closed geometric path in 2D plane</entry>
<entry>closed geometric path in 2D plane</entry>
</row>
</row>
<row>
<row>
<entry>serial</entry>
<entry><type>real</type></entry>
<entry><type>float4</type></entry>
<entry>single precision floating-point number</entry>
</row>
<row>
<entry><type>smallint</type></entry>
<entry><type>int2</type></entry>
<entry>signed two-byte integer</entry>
</row>
<row>
<entry><type>serial</type></entry>
<entry></entry>
<entry></entry>
<entry>
unique id for indexing and cross-reference
</entry>
<entry>
autoincrementing four-byte integer
</entry>
</row>
</row>
<row>
<row>
<entry>
text
</entry>
<entry>
<type>text</type>
</entry>
<entry></entry>
<entry></entry>
<entry>variable-length character string</entry>
<entry>variable-length character string</entry>
</row>
</row>
<row>
<row>
<entry>
time
</entry>
<entry>
<type>time [ without time zone ]</type>
</entry>
<entry>
time [ without time zone ]
</entry>
<entry></entry>
<entry>time of day</entry>
<entry>time of day</entry>
</row>
</row>
<row>
<row>
<entry>
timetz
</entry>
<entry>
<type>time with time zone</type>
</entry>
<entry>
time with time zone
</entry>
<entry></entry>
<entry>time of day, including time zone</entry>
<entry>time of day, including time zone</entry>
</row>
</row>
<row>
<row>
<entry>timestamp</entry>
<entry><type>timestamp [ with time zone ]</type></entry>
<entry>timestamp [ with time zone ]</entry>
<entry></entry>
<entry>date/time</entry>
<entry>date and time</entry>
</row>
<row>
<entry>varchar(n)</entry>
<entry>character varying(n)</entry>
<entry>variable-length character string</entry>
</row>
</row>
</tbody>
</tbody>
</tgroup>
</tgroup>
</table>
</table>
</para>
</para>
<para>
<note>
<note>
<title>Compatibility</title>
<para>
<para>
The <type>cidr</type> and <type>inet</type> types are designed to handle any IP type
The following types (or spellings thereof) are specified by SQL:
but only ipv4 is handled in the current implementation.
<type>bit</type>, <type>bit varying</type>, <type>boolean</type>,
Everything here that talks about ipv4 will apply to ipv6 in a
<type>char</type>, <type>character</type>, <type>character
future release.
varying</type>, <type>varchar</type>, <type>date</type>,
<type>double precision</type>, <type>integer</type>,
<type>interval</type>, <type>numeric</type>, <type>decimal</type>,
<type>real</type>, <type>smallint</type>, <type>time</type>,
<type>timestamp</type> (both with or without time zone).
</para>
</para>
</note>
</note>
</para>
<para>
<table tocentry="1">
<title><productname>Postgres</productname> Function Constants</title>
<titleabbrev>Constants</titleabbrev>
<tgroup cols="3">
<thead>
<row>
<entry><productname>Postgres</productname> Function</entry>
<entry><acronym>SQL92</acronym> Constant</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>date('now')</entry>
<entry>current_date</entry>
<entry>date of current transaction</entry>
</row>
<row>
<entry>time('now')</entry>
<entry>current_time</entry>
<entry>time of current transaction</entry>
</row>
<row>
<entry>timestamp('now')</entry>
<entry>current_timestamp</entry>
<entry>date and time of current transaction</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<productname>Postgres</productname> has features at the forefront of
<acronym>ORDBMS</acronym> development. In addition to
<acronym>SQL99</acronym> conformance, substantial portions
of <acronym>SQL92</acronym> are also supported.
Although we strive for <acronym>SQL92</acronym> compliance,
there are some aspects of the standard
that are ill considered and which should not live through subsequent standards.
<productname>Postgres</productname> will not make great efforts to
conform to these features; however, these tend to apply in little-used
or obsure cases, and a typical user is not likely to run into them.
</para>
<para>
<para>
Most of the input and output functions corresponding to the
Most of the input and output functions corresponding to the
...
@@ -259,19 +252,9 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
...
@@ -259,19 +252,9 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
Some of the input and output functions are not invertible. That is,
Some of the input and output functions are not invertible. That is,
the result of an output function may lose precision when compared to
the result of an output function may lose precision when compared to
the original input.
the original input.
<note>
<para>
Floating point numbers are allowed to retain
most of the intrinsic precision of the type (typically 15 digits for doubles,
6 digits for 4-byte floats).
Other types with underlying floating point fields (e.g. geometric
types) carry similar precision.
</para>
</note>
</para>
</para>
<sect1 id="
numeric-types
">
<sect1 id="
datatype-numeric
">
<title>Numeric Types</title>
<title>Numeric Types</title>
<para>
<para>
...
@@ -293,42 +276,32 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
...
@@ -293,42 +276,32 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
<entry>Range</entry>
<entry>Range</entry>
</row>
</row>
</thead>
</thead>
<tbody>
<tbody>
<row>
<row>
<entry>decimal</entry>
<entry>smallint</entry>
<entry>variable</entry>
<entry>User-specified precision</entry>
<entry>no limit</entry>
</row>
<row>
<entry>float4</entry>
<entry>4 bytes</entry>
<entry>Variable-precision</entry>
<entry>6 decimal places</entry>
</row>
<row>
<entry>float8</entry>
<entry>8 bytes</entry>
<entry>Variable-precision</entry>
<entry>15 decimal places</entry>
</row>
<row>
<entry>int2</entry>
<entry>2 bytes</entry>
<entry>2 bytes</entry>
<entry>Fixed-precision</entry>
<entry>Fixed-precision</entry>
<entry>-32768 to +32767</entry>
<entry>-32768 to +32767</entry>
</row>
</row>
<row>
<row>
<entry>int
4
</entry>
<entry>int
eger
</entry>
<entry>4 bytes</entry>
<entry>4 bytes</entry>
<entry>Usual choice for fixed-precision</entry>
<entry>Usual choice for fixed-precision</entry>
<entry>-2147483648 to +2147483647</entry>
<entry>-2147483648 to +2147483647</entry>
</row>
</row>
<row>
<row>
<entry>
int8
</entry>
<entry>
bigint
</entry>
<entry>8 bytes</entry>
<entry>8 bytes</entry>
<entry>Very large range fixed-precision</entry>
<entry>Very large range fixed-precision</entry>
<entry>~18 decimal places</entry>
<entry>about 18 decimal places</entry>
</row>
<row>
<entry>decimal</entry>
<entry>variable</entry>
<entry>User-specified precision</entry>
<entry>no limit</entry>
</row>
</row>
<row>
<row>
<entry>numeric</entry>
<entry>numeric</entry>
...
@@ -336,6 +309,20 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
...
@@ -336,6 +309,20 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
<entry>User-specified precision</entry>
<entry>User-specified precision</entry>
<entry>no limit</entry>
<entry>no limit</entry>
</row>
</row>
<row>
<entry>real</entry>
<entry>4 bytes</entry>
<entry>Variable-precision</entry>
<entry>6 decimal places</entry>
</row>
<row>
<entry>double precision</entry>
<entry>8 bytes</entry>
<entry>Variable-precision</entry>
<entry>15 decimal places</entry>
</row>
<row>
<row>
<entry>serial</entry>
<entry>serial</entry>
<entry>4 bytes</entry>
<entry>4 bytes</entry>
...
@@ -353,11 +340,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
...
@@ -353,11 +340,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.46 2000/12/22 18:57:49 pe
</para>
</para>
<para>
<para>
The <type>
int8
</type> type may not be available on all platforms since
The <type>
bigint
</type> type may not be available on all platforms since
it relies on compiler support for eight-byte integers.
it relies on compiler support for eight-byte integers.
</para>
</para>
<sect2>
<sect2
id="datatype-serial"
>
<title>The Serial Type</title>
<title>The Serial Type</title>
<para>
<para>
...
@@ -403,7 +390,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -403,7 +390,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</sect2>
</sect2>
</sect1>
</sect1>
<sect1 id="
monetary-types
">
<sect1 id="
datatype-money
">
<title>Monetary Type</title>
<title>Monetary Type</title>
<note>
<note>
...
@@ -455,15 +442,15 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -455,15 +442,15 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</sect1>
</sect1>
<sect1 id="
character-types
">
<sect1 id="
datatype-character
">
<title>Character Types</title>
<title>Character Types</title>
<para>
<para>
<acronym>SQL
92
</acronym> defines two primary character types:
<acronym>SQL</acronym> defines two primary character types:
<type>char
</type> and <type>varchar
</type>.
<type>char
acter</type> and <type>character varying
</type>.
<productname>Postgres</productname> supports these types, in
<productname>Postgres</productname> supports these types, in
addition to the more general <type>text</type> type,
addition to the more general <type>text</type> type,
which unlike <type>
varchar
</type>
which unlike <type>
character varying
</type>
does not require an explicit declared upper
does not require an explicit declared upper
limit on the size of the field.
limit on the size of the field.
</para>
</para>
...
@@ -483,16 +470,16 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -483,16 +470,16 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</thead>
</thead>
<tbody>
<tbody>
<row>
<row>
<entry>
"char"
</entry>
<entry>
character(n), char(n)
</entry>
<entry>
1 byte
</entry>
<entry>
(4+n) bytes
</entry>
<entry><acronym>SQL
92
</acronym>-compatible</entry>
<entry><acronym>SQL</acronym>-compatible</entry>
<entry>
Single character
</entry>
<entry>
Fixed-length blank padded
</entry>
</row>
</row>
<row>
<row>
<entry>char(n)</entry>
<entry>char
acter varying(n), varchar
(n)</entry>
<entry>(4+n) bytes</entry>
<entry>(4+n) bytes</entry>
<entry><acronym>SQL
92
</acronym>-compatible</entry>
<entry><acronym>SQL</acronym>-compatible</entry>
<entry>
Fixed-length blank padded
</entry>
<entry>
Variable-length with limit
</entry>
</row>
</row>
<row>
<row>
<entry>text</entry>
<entry>text</entry>
...
@@ -500,26 +487,32 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -500,26 +487,32 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
<entry>Most flexible</entry>
<entry>Most flexible</entry>
<entry>Variable unlimited length</entry>
<entry>Variable unlimited length</entry>
</row>
</row>
<row>
<entry>varchar(n)</entry>
<entry>(4+n) bytes</entry>
<entry><acronym>SQL92</acronym>-compatible</entry>
<entry>Variable-length with limit</entry>
</row>
</tbody>
</tbody>
</tgroup>
</tgroup>
</table>
</table>
<note>
<para>
Although the type <type>text</type> is not SQL-compliant, many
other RDBMS packages have it as well.
</para>
</note>
</para>
</para>
<para>
<para>
There is one other fixed-length character type in <productname>Postgres</productname>.
There are two other fixed-length character types in
The <type>name</type> type exists <emphasis>only</emphasis> for
<productname>Postgres</productname>. The <type>name</type> type
storage of internal catalog names and
exists <emphasis>only</emphasis> for storage of internal catalog
is not intended for use by the general user.
names and is not intended for use by the general user. Its length
Its length is currently defined as 32 bytes (31 characters plus terminator)
is currently defined as 32 bytes (31 characters plus terminator)
but should be reference using NAMEDATALEN.
but should be referenced using the macro
The length is set at compile time (and is therefore adjustable for
<symbol>NAMEDATALEN</symbol>. The length is set at compile time
special uses); the default maximum length may change in a future release.
(and is therefore adjustable for special uses); the default
maximum length may change in a future release. The type
<type>"char"</type> (note the quotes) is different from
<type>char(1)</type> in that it only uses one byte of storage. It
is internally used in the system catalogs as a poor-man's
enumeration type.
</para>
</para>
<para>
<para>
...
@@ -535,6 +528,11 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -535,6 +528,11 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</row>
</row>
</thead>
</thead>
<tbody>
<tbody>
<row>
<entry>"char"</entry>
<entry>1 byte</entry>
<entry>Single character internal type</entry>
</row>
<row>
<row>
<entry>name</entry>
<entry>name</entry>
<entry>32 bytes</entry>
<entry>32 bytes</entry>
...
@@ -547,7 +545,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -547,7 +545,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</sect1>
</sect1>
<sect1 id="dat
etime-types
">
<sect1 id="dat
atype-datetime
">
<title>Date/Time Types</title>
<title>Date/Time Types</title>
<para>
<para>
...
@@ -641,7 +639,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -641,7 +639,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</para>
</para>
<sect2>
<sect2
id="datatype-datetime-input"
>
<title>Date/Time Input</title>
<title>Date/Time Input</title>
<para>
<para>
...
@@ -658,7 +656,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -658,7 +656,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</para>
</para>
<para>
<para>
See <xref
endterm="datetime-appendix-title" linkend="datetime-appendix-title
">
See <xref
linkend="datetime-appendix
">
for the exact parsing rules of date/time input and for the recognized time zones.
for the exact parsing rules of date/time input and for the recognized time zones.
</para>
</para>
...
@@ -956,7 +954,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
...
@@ -956,7 +954,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
</para>
</para>
<para>
<para>
Refer to <xref
endterm="timezone-title" linkend="timezon
e"> for
Refer to <xref
linkend="datatype-timezone-tabl
e"> for
more examples of time zones.
more examples of time zones.
</para>
</para>
</sect3>
</sect3>
...
@@ -984,8 +982,8 @@ January 8 04:05:06 1999 PST
...
@@ -984,8 +982,8 @@ January 8 04:05:06 1999 PST
</para>
</para>
<para>
<para>
<table tocentry="1" id="
timezon
e">
<table tocentry="1" id="
datatype-timezone-tabl
e">
<title
id="timezone-title"
><productname>Postgres</productname> Time Zone Input</title>
<title><productname>Postgres</productname> Time Zone Input</title>
<titleabbrev>Time Zone Inputs</titleabbrev>
<titleabbrev>Time Zone Inputs</titleabbrev>
<tgroup cols="2">
<tgroup cols="2">
<thead>
<thead>
...
@@ -1112,7 +1110,7 @@ January 8 04:05:06 1999 PST
...
@@ -1112,7 +1110,7 @@ January 8 04:05:06 1999 PST
</sect2>
</sect2>
<sect2>
<sect2
id="datatype-datetime-output"
>
<title>Date/Time Output</title>
<title>Date/Time Output</title>
<para>
<para>
...
@@ -1231,7 +1229,7 @@ January 8 04:05:06 1999 PST
...
@@ -1231,7 +1229,7 @@ January 8 04:05:06 1999 PST
</sect2>
</sect2>
<sect2>
<sect2
id="datatype-timezones"
>
<title>Time Zones</title>
<title>Time Zones</title>
<para>
<para>
...
@@ -1351,7 +1349,7 @@ January 8 04:05:06 1999 PST
...
@@ -1351,7 +1349,7 @@ January 8 04:05:06 1999 PST
</sect2>
</sect2>
<sect2>
<sect2
id="datatype-datetime-internals"
>
<title>Internals</title>
<title>Internals</title>
<para>
<para>
...
@@ -1370,22 +1368,21 @@ January 8 04:05:06 1999 PST
...
@@ -1370,22 +1368,21 @@ January 8 04:05:06 1999 PST
</sect1>
</sect1>
<sect1 id="
boolean-type
">
<sect1 id="
datatype-boolean
">
<title>Boolean Type</title>
<title>Boolean Type</title>
<para>
<para>
<productname>Postgres</productname> supports <type>bool</type> as
<productname>Postgres</productname> supports the
the <acronym>SQL99</acronym> boolean type.
<acronym>SQL99</acronym> <type>boolean</type> type.
<type>bool</type> can have one of only two states: 'true' or 'false'.
<type>boolean</type> can have one of only two states: 'true' or
A third state, 'unknown', is not
'false'. A third state, 'unknown', is represented by the SQL NULL
implemented and is not suggested in <acronym>SQL99</acronym>;
state. <type>boolean</type> can be used in any boolean expression,
<acronym>NULL</acronym> is an
and boolean expressions always evaluate to a result compatible
effective substitute. <type>bool</type> can be used in any boolean expression,
with this type.
and boolean expressions
</para>
always evaluate to a result compatible with this type.</para>
<para>
<para>
<type>bool</type> uses 1 byte of storage.
<type>bool
ean
</type> uses 1 byte of storage.
</para>
</para>
<para>
<para>
...
@@ -1417,7 +1414,7 @@ January 8 04:05:06 1999 PST
...
@@ -1417,7 +1414,7 @@ January 8 04:05:06 1999 PST
</para>
</para>
</sect1>
</sect1>
<sect1 id="
geometric-types
">
<sect1 id="
datatype-geometric
">
<title>Geometric Types</title>
<title>Geometric Types</title>
<para>
<para>
...
@@ -1746,7 +1743,7 @@ January 8 04:05:06 1999 PST
...
@@ -1746,7 +1743,7 @@ January 8 04:05:06 1999 PST
</sect1>
</sect1>
<sect1 id="net-types">
<sect1 id="
datatype-
net-types">
<title>Network Address Data Types</title>
<title>Network Address Data Types</title>
<para>
<para>
...
@@ -1755,7 +1752,7 @@ January 8 04:05:06 1999 PST
...
@@ -1755,7 +1752,7 @@ January 8 04:05:06 1999 PST
types, because these types offer input error checking and several
types, because these types offer input error checking and several
specialized operators and functions.
specialized operators and functions.
<table tocentry="1" id="net-types-table">
<table tocentry="1" id="
datatype-
net-types-table">
<title>Network Address Data Types</title>
<title>Network Address Data Types</title>
<tgroup cols="4">
<tgroup cols="4">
<thead>
<thead>
...
@@ -1799,7 +1796,7 @@ January 8 04:05:06 1999 PST
...
@@ -1799,7 +1796,7 @@ January 8 04:05:06 1999 PST
</para>
</para>
<sect2 id="
inet-type
">
<sect2 id="
datatype-inet
">
<title><type>inet</type></title>
<title><type>inet</type></title>
<para>
<para>
...
@@ -1825,7 +1822,7 @@ January 8 04:05:06 1999 PST
...
@@ -1825,7 +1822,7 @@ January 8 04:05:06 1999 PST
</para>
</para>
</sect2>
</sect2>
<sect2 id="
cidr-type
">
<sect2 id="
datatype-cidr
">
<title><type>cidr</></title>
<title><type>cidr</></title>
<para>
<para>
...
@@ -1918,7 +1915,7 @@ January 8 04:05:06 1999 PST
...
@@ -1918,7 +1915,7 @@ January 8 04:05:06 1999 PST
</para>
</para>
</sect2>
</sect2>
<sect2 id="inet-vs-cidr">
<sect2 id="
datatype-
inet-vs-cidr">
<title><type>inet</type> vs <type>cidr</type></title>
<title><type>inet</type> vs <type>cidr</type></title>
<para>
<para>
...
@@ -1936,7 +1933,7 @@ January 8 04:05:06 1999 PST
...
@@ -1936,7 +1933,7 @@ January 8 04:05:06 1999 PST
</para>
</para>
</sect2>
</sect2>
<sect2 id="
macaddr-type
">
<sect2 id="
datatype-macaddr
">
<title><type>macaddr</></>
<title><type>macaddr</></>
<para>
<para>
...
@@ -1955,6 +1952,40 @@ January 8 04:05:06 1999 PST
...
@@ -1955,6 +1952,40 @@ January 8 04:05:06 1999 PST
</sect1>
</sect1>
<sect1 id="datatype-bit">
<title>Bit String Types</title>
<para>
Bit strings are strings of 1's and 0's. They can be used to store
or visualize bit masks. There are two SQL bit types:
<type>BIT(<replaceable>x</replaceable>)</type> and <type>BIT
VARYING(<replaceable>x</replaceable>)</type>; the
<replaceable>x</replaceable> specifies the maximum length.
<type>BIT</type> type data is automatically padded with 0's on the
right to the maximum length, <type>BIT VARYING</type> is of
variable length. <type>BIT</type> without length is requivalent
to <literal>BIT(1)</literal>, <type>BIT VARYING</type> means
unlimited length. Input data that is longer than the allowed
length will be truncated. Refer to <xref
linkend="sql-syntax-bit-strings"> for information about the syntax
of bit string constants. Bit-logical operators and string
manipulation functions are available; see <xref
linkend="functions">.
</para>
<informalexample>
<para>
Some examples:
<programlisting>
CREATE TABLE test (a BIT(3), b BIT VARYING(5));
INSERT INTO test VALUES (B'101', B'00');
SELECT SUBSTRING(b FROM 1 FOR 2) FROM test;
</programlisting>
</para>
</informalexample>
</sect1>
</chapter>
</chapter>
<!-- Keep this comment at the end of the file
<!-- Keep this comment at the end of the file
...
...
doc/src/sgml/func.sgml
View file @
526427f6
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.4
6 2000/12/22 18:00:24 tgl
Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.4
7 2001/01/13 18:34:51 petere
Exp $ -->
<chapter id="functions">
<chapter id="functions">
<title>Functions and Operators</title>
<title>Functions and Operators</title>
...
@@ -184,42 +184,102 @@
...
@@ -184,42 +184,102 @@
<entry>@ -5.0</entry>
<entry>@ -5.0</entry>
<entry>5.0</entry>
<entry>5.0</entry>
</row>
</row>
<row>
<entry> <literal>&</literal> </entry>
<entry>Binary AND</entry>
<entry>91 & 15</entry>
<entry>11</entry>
</row>
<row>
<entry> <literal>|</literal> </entry>
<entry>Binary OR</entry>
<entry>32 | 3</entry>
<entry>35</entry>
</row>
<row>
<entry> <literal>#</literal> </entry>
<entry>Binary XOR</entry>
<entry>17 # 5</entry>
<entry>20</entry>
</row>
<row>
<entry> <literal>~</literal> </entry>
<entry>Binary NOT</entry>
<entry>~1</entry>
<entry>-2</entry>
</row>
<row>
<entry> << </entry>
<entry>Binary shift left</entry>
<entry>1 << 4</entry>
<entry>16</entry>
</row>
<row>
<entry> >> </entry>
<entry>Binary shift right</entry>
<entry>8 >> 2</entry>
<entry>2</entry>
</row>
</tbody>
</tbody>
</tgroup>
</tgroup>
</table>
</table>
<!--
<para>
<ROW>
The <quote>binary</quote> operators are also available for the bit
<ENTRY> & </ENTRY>
string types <type>BIT</type> and <type>BIT VARYING</type>.
<ENTRY>Binary AND</ENTRY>
<ENTRY>91 & 15</ENTRY>
<table>
</ROW>
<title>Bit String Binary Operators</title>
<ROW>
<ENTRY> | </ENTRY>
<tgroup cols="2">
<ENTRY>Binary OR</ENTRY>
<thead>
<ENTRY>32 | 3</ENTRY>
<row>
</ROW>
<entry>Example</entry>
<ROW>
<entry>Result</entry>
<ENTRY> # </ENTRY>
</row>
<ENTRY>Binary XOR</ENTRY>
</thead>
<ENTRY>15 # 4</ENTRY>
</ROW>
<tbody>
<ROW>
<row>
<ENTRY> ~ </ENTRY>
<entry>B'10001' & B'01101'</entry>
<ENTRY>Binary NOT</ENTRY>
<entry>00001</entry>
<ENTRY>~1</ENTRY>
</row>
</ROW>
<row>
<ROW>
<entry>B'10001' | B'01101'</entry>
<ENTRY> << </ENTRY>
<entry>11101</entry>
<ENTRY>Binary shift left</ENTRY>
</row>
<ENTRY>1 << 4</ENTRY>
<row>
</ROW>
<entry>B'10001' # B'01101'</entry>
<ROW>
<entry>11110</entry>
<ENTRY> >> </ENTRY>
</row>
<ENTRY>Binary shift right</ENTRY>
<row>
<ENTRY>8 >> 2</ENTRY>
<entry>~ B'10001'</entry>
</ROW>
<entry>01110</entry>
-->
</row>
<row>
<entry>B'10001' << 3</entry>
<entry>01000</entry>
</row>
<row>
<entry>B'10001' >> 2</entry>
<entry>00100</entry>
</row>
</tbody>
</tgroup>
</table>
Bit string arguments to <literal>&</literal>, <literal>|</literal>,
and <literal>#</literal> must be of equal length. When bit
shifting, the original length of the string is preserved, as shown
here.
</para>
<table tocentry="1">
<table tocentry="1">
<title>Mathematical Functions</title>
<title>Mathematical Functions</title>
...
@@ -484,7 +544,8 @@
...
@@ -484,7 +544,8 @@
wary of potential effects of the automatic padding when using the
wary of potential effects of the automatic padding when using the
<type>CHARACTER</type> type. Generally the functions described
<type>CHARACTER</type> type. Generally the functions described
here also work on data of non-string types by converting that data
here also work on data of non-string types by converting that data
to a string representation first.
to a string representation first. Some functions also exist
natively for bit string types.
</para>
</para>
<para>
<para>
...
...
doc/src/sgml/syntax.sgml
View file @
526427f6
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.3
3 2001/01/08 22:07:47 tgl
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.3
4 2001/01/13 18:34:51 petere
Exp $
-->
-->
<chapter id="sql-syntax">
<chapter id="sql-syntax">
...
@@ -232,7 +232,7 @@ SELECT 'foo' 'bar';
...
@@ -232,7 +232,7 @@ SELECT 'foo' 'bar';
</para>
</para>
</sect3>
</sect3>
<sect3>
<sect3
id="sql-syntax-bit-strings"
>
<title>Bit String Constants</title>
<title>Bit String Constants</title>
<para>
<para>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment