In PostgreSQL source code and its extensions like Apache/age I find Datum data type is used everywhere. I’d like to know where it’s defined and what it’s used for.
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
2
Answers
It’s the backend-internal representation of a single value of any SQL
data type. The code using the Datum has to know which type it is,
since the Datum itself doesn’t contain that information. Usually,
C code will work with a value in a "native" representation, and then
convert to or from Datum in order to pass the value through
data-type-independent interfaces.
In simpler terms, it’s a unit of data stored in the database. When you work with SQL queries on a PostgreSQL database, you interact with Datums indirectly through SQL queries and data manipulation commands. You can perform operations on them like selecting, inserting, updating, or deleting them within tables and can even transform them using the expressions.