Press "Enter" to skip to content

User-Defined Types in PostgreSQL

Grant Fritchey dives into functionality:

I’m sure I’m not alone when I say, sometimes I get sidetracked. In this particular instance, I hadn’t intended to start learning about User-Defined Types (UDT) in PostgreSQL – I just wanted to test a behavior that involved creating a UDT. But, once I started reading, I was hooked. I mean, four distinct UDTs with different behaviors? That’s pretty cool. Let’s get into it.

Read on to learn more about why there are so many user-defined types in Postgres. Looking at the list, I do really like what they have available. You can, of course, replicate the functionality otherwise (e.g., check constraints on a regular column for DOMAIN, foreign key link to a lookup table for ENUM), but it’s nice to have those types right there for clarity of design and so you don’t accidentally forget to apply an appropriate constraint.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.