How User-Defined Types work in PostgreSQL: a complete guide


 

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.

What is a User-Defined Type (UDT), and why do we have them?

First, it’s PostgreSQL, so I have to address the true User-Defined Type, not simply the derived types that we’re going to talk about in