Extending Types
PostgreSQL has a plethora of built-in data types (see Chapter 2, “PostgreSQL Data Types”). However, in specific cases, it might be advantageous to create custom-defined data types.
All the data types in PostgreSQL can be defined as belonging to one of the following cases: base types or composites.
Base types, like int4, are written in C and are compiled into the system. However, custom data types can be compiled as shared objects and linked to the back end by using the CREATE TYPE command.
Composite types are created whenever a new table is created. At first it might seem counterintuitive to think of a table as a type. However, tables are merely collections of single data types grouped in a specific order. In that way, a table ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access