# PostgreSQL/Data Types
## Standard Data Types

PostgreSQL supports the basic set of data types which are defined by the SQL standard and described in the wikibook SQL (but: CLOB is called TEXT and BLOB is called BYTEA).

### Character Types

    Character (CHAR)
    Character Varying (VARCHAR)
    Character Large Object (TEXT/CLOB)

### Binary Types

    Binary (BINARY)
    Binary Varying (VARBINARY)
    Binary Large Object (BYTEA/BLOB)

### Numeric Types

    Exact Numeric Types (NUMERIC, DECIMAL, SMALLINT, INTEGER, BIGINT)
    Approximate Numeric Types (FLOAT, REAL, DOUBLE PRECISION)

### Datetime Types

    (DATE, TIME, TIMESTAMP. With and without timezone.)

### Interval Type

    (INTERVAL)

### JSON

    JSON and JSONB stores data according to RFC 7159. The difference between the two data types is, that JSON internally uses a pure text representation whereas JSONB uses a decomposed binary format.
In addition to this basic types there are some more predefined types as well as a mechanism to define own, composite data types.

## Extensions to the Standard
### SERIAL

    SERIAL generates a sequence of integer values, usually used as a primary key. However SERIAL is not a real data type. Under the hood, it uses the type INTEGER and accomplishes it with a sequence.

### ENUM

    It defines a static, ordered set of values, eg: colors, days of the week, ... .

### MONETARY

    It represents currency values with fixed fractional precision.

### GEOMETRIC

    POINT, LINE, LSEG, BOX, PATH, POLYGON, and CIRCLE are supported 'out of the box' (without the need to install the extension PostGIS).

### Network Address Types

    MACADDR, MACADDR8: They hold MAC addresses.
    INET: It holds an IPv4 or IPv6 host address and optionally a netmask, eg: 123.45.67.89 or 192.168.0.1/24. INET accepts nonzero bits to the right of the netmask (on input).
    CIDR: It holds an IPv4 or IPv6 network specification and optionally a netmask, eg: 123.45.67.89 or 192.168.0.0/24. CIDR does not accept nonzero bits to the right of the netmask (on input).

### Bit Types

    BIT(n) and BIT VARYING(n) stores '0's and '1's in the same way as CHAR stores character.

### UUID

    It stores a sequence of 128 bits according to RFC 4122. Its main usage is to hold unique values.

### HSTORE

    key/value pairs (via EXTENSION HSTORE).

## Special Types
### Arrays

According to SQL:2011 PostgreSQL supports arrays. Columns of a table can be defined as variable-length multidimensional arrays of the above-presented data types.

### Composite Types

You can create new types by arranging an ordered set of data types - like a struct or record in other programming languages. This new type can be used at all places where the predefined data types are applicable (columns, function parameters, ...).

### Range Types

Range types are data types representing a range of values, eg: an integer range or a date or timestamp range. This is similar to a BETWEEN constraint. But it offers the additional possibility to ensure, that values of different rows do not overlap; see the description of an EXCLUSION CONSTRAINT with a GIST index

## References

* ↑ https://www.postgresql.org/docs/current/datatype.html