Type¶
User defined data type. here are five forms of types. They respectively create a composite type, an enum type, a range type, a base type, or a shell type. A shell type is simply a placeholder for a type to be defined later. Shell types are needed as forward references when creating range types and base types, as discussed in those sections.
Properties¶
| Property | Type | Required | Description |
|---|---|---|---|
name |
string |
— | The name of the type to be created. The type name must be distinct from the name of any existing type or domain in the same schema. (Because tables have associated data types, the type name must also be distinct from the name of any existing table in the same schema.). |
schema |
string |
— | The schema to create the type in. |
owner |
string |
— | The role name of the superuser who owns the server. |
sql |
string |
— | User-provided raw SQL snippet. |
type |
base | composite | enum | range |
— | Specifies the form of the type. Defaults to composite. |
input |
string |
— | Function that converts the type's external textual representation to the internal representation used by the operators and functions defined for the type. |
output |
string |
— | Function that converts the type's external binary representation to the internal representation. |
receive |
string |
— | Optional function to convert the type's external binary representation to the internal representation. |
send |
string |
— | Optional converts from the internal representation to the external binary representation. |
typmod_in |
string |
— | Type Modifier Input Function. |
typmod_out |
string |
— | Type Modifier Output Function. |
analyze |
string |
— | Optional function that performs type-specific statistics collection for columns of the data type. |
internal_length |
integer | "VARIABLE" |
— | Internal Length. |
passed_by_value |
boolean |
— | Indicates that values of this data type are passed by value, rather than by reference. Default: false. |
alignment |
char | double | int2 | int4 |
— | Specifies the storage alignment required for the data type. The allowed values equate to alignment on 1, 2, 4, or 8 byte boundaries. |
storage |
plain | extended | external | main |
— | Allows selection of storage strategies for variable-length data types. (Only plain is allowed for fixed-length types.) plain specifies that data of the type will always be stored in-line and not compressed. extended specifies that the system will first try to compress a long data value, and will move the value out of the main table row if it's still too long. external allows the value to be moved out of the main table, but the system will not try to compress it. main allows compression, but discourages moving the value out of the main table. (Data items with this storage strategy might still be moved out of the main table if there is no other way to make a row fit, but they will be kept in the main table preferentially over extended and external items.). |
like_type |
string |
— | Provides an alternative method for specifying the basic representation properties of a data type: copy them from some existing type. The values of internal_length, passed_by_value, alignment, and storage are copied from the named type. |
category |
A | B | C | D | E | G | I | N | P | R | S | T | U | V | X |
— | Used to help control which implicit cast will be applied in ambiguous situations. |
preferred |
string |
— | Used to help control which implicit cast will be applied in ambiguous situations. |
default |
boolean | integer | null | number | string |
— | Value to use instead of NULL to use as a default. |
element |
string |
— | The type being created is an array; this specifies the type of the array elements. |
delimiter |
string |
— | The delimiter character to be used between values in arrays made of this type. |
collatable |
boolean |
— | This type's operations can use collation information. Default: false. |
columns |
array of object |
— | Type Columns. Minimum length: 1. |
enum |
array of string |
— | A list of quoted labels, each of which must be less than NAMEDATALEN bytes long (64 bytes in a standard PostgreSQL build). Minimum length: 1. |
subtype |
string |
— | The name of the element type that the range type will represent ranges of. |
subtype_opclass |
string |
— | The name of a b-tree operator class for the subtype. |
collation |
string |
— | The name of an existing collation to use for the range type. |
canonical |
string |
— | Function used to convert range values into canonical form. |
subtype_diff |
string |
— | Function to provide the difference between two values. |
comment |
string |
— | An optional comment about the type. |
dependencies |
dependencies | — | Database objects this object is dependent upon. |
columns[]¶
| Property | Type | Required | Description |
|---|---|---|---|
name |
string |
yes | The name of an attribute (column) for the composite type. |
data_type |
string |
yes | The name of an existing data type to become a column of the composite type. |
collation |
string |
— | The name of an existing collation to use for the column. |
Mutually exclusive forms¶
Exactly one of these must hold:
sql, withouttypetype, withoutsql
No other properties are accepted.
Source: schemata/type.yml · Resolved JSON Schema: type.json