shows all general-purpose data types
- available to users. Most of the alternative names listed in the
+ included in the standard distribution. Most of the alternative names
+ listed in the
Aliases
column are the names used internally by
Postgres for historical reasons. In
addition, some internally used or deprecated types are available,
- but they are not documented here. Many of the built-in types have
- obvious external formats. However, several types are either unique
- to
Postgres, such as open and closed
- paths, or have several possibilities for formats, such as the date
- and time types.
+ but they are not listed here.
|
timestamp [ with time zone ]
timestamptz
- date and time
+ date and time, including time zone
+ Each data type has an external representation determined by its input
+ and output functions. Many of the built-in types have
+ obvious external formats. However, several types are either unique
+ to
Postgres, such as open and closed
+ paths, or have several possibilities for formats, such as the date
+ and time types.
Most of the input and output functions corresponding to the
base types (e.g., integers and floating point numbers) do some
error-checking.
+ 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 original input.
+
+
Some of the operators and functions (e.g.,
addition and multiplication) do not perform run-time error-checking in the
interests of improving execution speed.
silently underflow or overflow.
- 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 original input.
-
-
Numeric Types
platform where this is actually the case.
+ SQL only specifies the integer types integer (or
+ int) and smallint. The type
+ bigint, and the type names int2,
+ int4, and int8 are extensions, which
+ are shared with various other RDBMS products.
+
+
If you have a column of type smallint or
... WHERE smallint_column = 42
will not use an index, because the system assigns type
- integer to the 42, and PostgreSQL currently cannot
- use an index when two different data types are involved. A
+ integer to the constant 42, and PostgreSQL currently
+ cannot use an index when two different data types are involved. A
workaround is to single-quote the constant, thus:
... WHERE smallint_column = '42'
- This will cause the system to delay the type resolution and will
+ This will cause the system to delay type resolution and will
assign the right type to the constant.
- SQL only specifies the integer types integer (or
- int) and smallint. The type
- bigint, and the type names int2,
- int4, and int8 are extensions, which
- are shared with various other RDBMS products.
-
-
Normally, the real type has a range of at least
- -1E+37 to +1E+37 with a precision of at least 6. The
+ -1E+37 to +1E+37 with a precision of at least 6 decimal digits. The
double precision type normally has a range of around
- -1E+308 to +1E+308 with a precision of at least 15. Values that
+ -1E+308 to +1E+308 with a precision of at least 15 digits. Values that
are too large or too small will cause an error. Rounding may
take place if the precision of an input number is too high.
Numbers too close to zero that are not representable as distinct
or abbreviations or plurals of these units;
Direction can be ago or
empty. The at sign (@>) is optional noise. The amounts
- of different quantities are implicitly added up with appropriate
+ of different units are implicitly added up with appropriate
sign accounting.
Quantities of days, hours, minutes, and seconds can be specified without
- explicit unit markings: for example, '1 12:59:10'> is read
+ explicit unit markings. For example, '1 12:59:10'> is read
the same as '1 day 12 hours 59 min 10 sec'>.
- 'now' is resolved when the value is inserted, 'current'
- 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'.)
- The output of the date and time styles is of course
+ The output of the date and time types is of course
only the date or time part in accordance with the above examples.
Although the date type
does not have an associated time zone, the
- time type can or does.
+ time type can.
Time zones in the real world can have no meaning unless
associated with a date as well as a time
since the offset may vary through the year with daylight savings