All Products
Search
Document Center

PolarDB:pg_type

Last Updated:Mar 28, 2026

The pg_type catalog stores information about data types.

  • Base types and enum types (scalar types) are created with CREATE TYPE.

  • Domains are created with CREATE DOMAIN.

  • A composite type is automatically created for each table in the database to represent the row structure of that table. You can also create composite types with CREATE TYPE AS.

Columns

ColumnTypeDescription
oidoidRow identifier.
typnamenameData type name.
typnamespaceoidOID of the namespace that contains this type.
typowneroidOwner of the type.
typlenint2For fixed-size types, the number of bytes in the internal representation. For variable-length types, a negative value: -1 indicates a varlena type (one that has a length word); -2 indicates a null-terminated C string.
typbyvalboolDetermines whether internal routines pass a value of this type by value or by reference. typbyval had better be false if typlen is not 1, 2, or 4 (or 8 on machines where Datum is 8 bytes). Variable-length types are always passed by reference. Note that typbyval can be false even if the length would allow pass-by-value.
typtypecharThe kind of type. See typtype values.
typcategorycharAn arbitrary classification used by the parser to determine which implicit casts should be preferred. See typcategory codes.
typispreferredbooltrue if this type is a preferred cast target within its typcategory.
typisdefinedbooltrue if the type is fully defined. false if this is a placeholder entry for a not-yet-defined type — in which case, only the type name, namespace, and OID can be relied on.
typdelimcharThe character that separates two values of this type when parsing array input. The delimiter is associated with the array element type, not the array type itself.
typrelidoidFor composite types, points to the pg_class entry that defines the corresponding table. (For a free-standing composite type, the pg_class entry doesn't really represent a table, but it is needed anyway for the type's pg_attribute entries to link to.) Zero for non-composite types.
typelemoidIf nonzero, identifies another row in pg_type that defines the type yielded by subscripting. Zero when typsubscript is zero, though it can also be zero when typsubscript is nonzero if the handler does not need typelem to determine the subscripting result type. A typelem dependency implies physical containment of the element type in this type, which may restrict DDL changes on the element type.
typarrayoidIf nonzero, identifies another row in pg_type that is the "true" array type having this type as its element type.
typinputregprocInput conversion function (text format).
typoutputregprocOutput conversion function (text format).
typreceiveregprocInput conversion function (binary format), or zero if none.
typsendregprocOutput conversion function (binary format), or zero if none.
typmodinregprocType modifier input function, or zero if the type does not support modifiers.
typmodoutregprocType modifier output function, or zero to use the standard format.
typanalyzeregprocCustom ANALYZE function, or zero to use the standard function.
typaligncharThe alignment required when storing a value of this type. Applies to disk storage and most in-memory representations. When multiple values are stored consecutively (for example, in a complete row on disk), padding is inserted before a value of this type so that it begins on the specified boundary, measured from the start of the first datum in the sequence. Possible values: c = char alignment (no alignment needed); s = short alignment (2 bytes on most machines); i = int alignment (4 bytes on most machines); d = double alignment (8 bytes on many machines).
typstoragecharFor varlena types (typlen = -1), indicates whether the type supports TOAST (The Oversized-Attribute Storage Technique) and what the default storage strategy is for columns of this type. Possible values: p (plain) = values must always be stored without compression or out-of-line storage; e (external) = values can be stored in a secondary TOAST relation (if the relation has one, see pg_class.reltoastrelid); m (main) = values can be compressed and stored inline; x (extended) = values can be compressed and/or moved to a secondary relation. x is the usual choice for TOAST-capable types. m values can also be moved to secondary storage, but only as a last resort (e and x values are moved first). Non-varlena types always use p.
typnotnullboolRepresents a NOT NULL constraint on the type. Used for domains only.
typbasetypeoidFor domains, identifies the base type. Zero for non-domain types.
typtypmodint4For domains, records the type modifier (typmod) applied to the base type. -1 if the base type does not use a type modifier, or if this type is not a domain.
typndimsint4Number of array dimensions for a domain over an array type (that is, typbasetype is an array type). Zero for types other than array domains.
typcollationoidThe collation of the type. Zero if the type does not support collations. A base type that supports collations has a nonzero value here, typically DEFAULT_COLLATION_OID. A domain over a collatable type can have a different collation OID from its base type if one was specified for the domain.
typdefaultbinpg_node_treeIf not null, the nodeToString() representation of a default expression for the type. Used only for domains.
typdefaulttextNull if the type has no associated default value. If typdefaultbin is not null, typdefault must contain a human-readable version of the default expression in typdefaultbin. If typdefaultbin is null and typdefault is not null, typdefault is the external representation of the type's default value, which can be fed to the type's input converter to produce a constant.
typaclaclitem[]Access privileges.
Note

For fixed-width types used in system tables, the size and alignment defined in pg_type must agree with the way the compiler lays out the column in a structure representing a table row.

typtype values

ValueType
bBase type
cComposite type (for example, a table's row type)
dDomain
eEnum type
pPseudo-type
rRange type

typcategory codes

The typcategory column uses single uppercase ASCII letters. Future system-defined categories will also use uppercase ASCII letters. All other ASCII characters are reserved for user-defined categories.

CodeCategory
AArray types
BBoolean types
CComposite types
DDate/time types
EEnum types
GGeometric types
INetwork address types
NNumeric types
PPseudo-types
RRange types
SString types
TTimespan types
UUser-defined types
VBit-string types
Xunknown type