How to list custom types using Postgres information_schema

后端 未结 7 1471
遥遥无期
遥遥无期 2020-12-28 12:40

I am trying to find the equivalent SQL of \\dT using the information_schema and can\'t seem to find anything. Does such a thing exist?

Example: If I add the followi

7条回答
  •  天命终不由人
    2020-12-28 12:58

    For reference, here is the SQL from \dT (pgAdmin uses the same or similar)

    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');
    

提交回复
热议问题