I need to retrieve a list of all the user defined data types in sql(oracle and postgres) using either an sql command or jdbc. For now I only know how to retrieve the source code with
SELECT text FROM all_source WHERE name='type'
Oracle has a data dictionary view for almost everything. You can select from ALL_TYPES and ALL_TYPE_ATTRS. The latter shows the owner of each type.
Postgres does not have the same functionality so you can use this query from here
SELECT n.nspname as schema, t.typname as type
FROM pg_type t
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
WHERE (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid))
AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid)
AND n.nspname NOT IN ('pg_catalog', 'information_schema')