Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What select query will list domains within Postgres?

I'm aware of the psql command that will list these, but I'm attempting to write an extension for Oracle's SQL Developer that will list them on the left-hand navigator panel. The XML format requires a select statement.

For example purposes, I'll include the code I cooked up for sequences:

<sql constrained="true">
    <![CDATA[SELECT relname FROM pg_class JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace WHERE relkind = 'S' AND nspname = :SCHEMA]]>
</sql>

I've attempted to figure it out for myself, but I don't see anything with my test domain names in pg_class or any other of those internal tables (though it must be in one, somewhere).

Does anyone have a hint?

like image 710
John O Avatar asked Aug 22 '26 22:08

John O


1 Answers

Asked too soon... here's a select query that will return domains from a specific schema:

SELECT typname FROM pg_catalog.pg_type JOIN pg_catalog.pg_namespace ON pg_namespace.oid = pg_type.typnamespace WHERE typtype = 'd' AND nspname = 'someschema'

Minor tweaking can also return enums, ranges, and composites/rows. More information in the docs.

like image 179
John O Avatar answered Aug 24 '26 12:08

John O



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!