I have the following table:
CREATE table contact (
id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
firstname text,
lastname text,
birthday timestamp with time zone NOT NULL,
path ltree
);
I want to query the column names and their data type. I am using this:
SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'contact';
This gives the correct results except for the ltree data type for which is gives USER-DEFINED:
column_name | data_type
-------------+--------------------------
id | bigint
firstname | text
lastname | text
birthday | timestamp with time zone
path | USER-DEFINED
(5 rows)
How can I get ltree as the data type instead?
I figured it out:
gives:
I learned about this trick from the docs:
https://www.postgresql.org/docs/current/infoschema-element-types.html