22.1. A User-Defined Data Type

Let's get started and see how you can add a user-defined data type to PostgreSQL. The standard distribution of PostgreSQL offers a set of predefined data types. In some cases these data types might not offer enough efficiency for your applications. If you have to store special information that cannot easily be modeled using standard data types, it can be useful to implement your own data type. Because this can easily be done, we have decided to provide a brief example.

The goal of this section is to implement a data type for storing information about spheres. Several files will be needed, as shown in Table 22.1.

Table 22.1. The Files Used in This Section
Filename Description
Makefile This file is used to run the ...

Get PHP and PostgreSQL: Advanced Web Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.