exec-ddl
CREATE TABLE pg_attribute (
    attrelid oid NOT NULL,
    attname text NOT NULL,
    atttypid oid NOT NULL,
    attstattarget bigint NOT NULL,
    attlen bigint NOT NULL,
    attnum bigint NOT NULL,
    attndims bigint NOT NULL,
    attcacheoff bigint NOT NULL,
    atttypmod bigint NOT NULL,
    attbyval boolean NOT NULL,
    attstorage text NOT NULL,
    attalign text NOT NULL,
    attnotnull boolean NOT NULL,
    atthasdef boolean NOT NULL,
    attisdropped boolean NOT NULL,
    attislocal boolean NOT NULL,
    attinhcount bigint NOT NULL,
    attcollation oid NOT NULL,
    attacl text[],
    attoptions text[],
    attfdwoptions text[],
    PRIMARY KEY (attrelid, attnum),
    UNIQUE INDEX pg_attribute_relid_attnam_index (attrelid, attname)
);
----
TABLE pg_attribute
 ├── attrelid oid not null
 ├── attname string not null
 ├── atttypid oid not null
 ├── attstattarget int not null
 ├── attlen int not null
 ├── attnum int not null
 ├── attndims int not null
 ├── attcacheoff int not null
 ├── atttypmod int not null
 ├── attbyval bool not null
 ├── attstorage string not null
 ├── attalign string not null
 ├── attnotnull bool not null
 ├── atthasdef bool not null
 ├── attisdropped bool not null
 ├── attislocal bool not null
 ├── attinhcount int not null
 ├── attcollation oid not null
 ├── attacl string[]
 ├── attoptions string[]
 ├── attfdwoptions string[]
 ├── INDEX primary
 │    ├── attrelid oid not null
 │    └── attnum int not null
 └── INDEX pg_attribute_relid_attnam_index
      ├── attrelid oid not null
      ├── attname string not null
      └── attnum int not null (storing)

exec-ddl
CREATE TABLE pg_attrdef (
    oid oid PRIMARY KEY,
    adrelid oid NOT NULL,
    adnum bigint NOT NULL,
    adbin text,
    adsrc text,
    UNIQUE INDEX pg_attrdef_adrelid_adnum_index (adrelid, adnum)
);
----
TABLE pg_attrdef
 ├── oid oid not null
 ├── adrelid oid not null
 ├── adnum int not null
 ├── adbin string
 ├── adsrc string
 ├── INDEX primary
 │    └── oid oid not null
 └── INDEX pg_attrdef_adrelid_adnum_index
      ├── adrelid oid not null
      ├── adnum int not null
      └── oid oid not null (storing)

exec-ddl
CREATE TABLE pg_collation (
    oid oid PRIMARY KEY,
    collname text NOT NULL,
    collnamespace oid NOT NULL,
    collowner oid NOT NULL,
    collencoding bigint NOT NULL,
    collcollate text NOT NULL,
    collctype text NOT NULL,
    UNIQUE INDEX pg_collation_name_enc_nsp_index (collname, collencoding, collnamespace)
);
----
TABLE pg_collation
 ├── oid oid not null
 ├── collname string not null
 ├── collnamespace oid not null
 ├── collowner oid not null
 ├── collencoding int not null
 ├── collcollate string not null
 ├── collctype string not null
 ├── INDEX primary
 │    └── oid oid not null
 └── INDEX pg_collation_name_enc_nsp_index
      ├── collname string not null
      ├── collencoding int not null
      ├── collnamespace oid not null
      └── oid oid not null (storing)

exec-ddl
CREATE TABLE pg_type (
    oid oid PRIMARY KEY,
    typname text NOT NULL,
    typnamespace oid NOT NULL,
    typowner oid NOT NULL,
    typlen bigint NOT NULL,
    typbyval boolean NOT NULL,
    typtype text NOT NULL,
    typcategory text NOT NULL,
    typispreferred boolean NOT NULL,
    typisdefined boolean NOT NULL,
    typdelim text NOT NULL,
    typrelid oid NOT NULL,
    typelem oid NOT NULL,
    typarray oid NOT NULL,
    typinput oid NOT NULL,
    typoutput oid NOT NULL,
    typreceive oid NOT NULL,
    typsend oid NOT NULL,
    typmodin oid NOT NULL,
    typmodout oid NOT NULL,
    typanalyze oid NOT NULL,
    typalign text NOT NULL,
    typstorage text NOT NULL,
    typnotnull boolean NOT NULL,
    typbasetype oid NOT NULL,
    typtypmod bigint NOT NULL,
    typndims bigint NOT NULL,
    typcollation oid NOT NULL,
    typdefaultbin text,
    typdefault text,
    typacl text[],
    UNIQUE INDEX pg_type_typname_nsp_index (typname, typnamespace)
);
----
TABLE pg_type
 ├── oid oid not null
 ├── typname string not null
 ├── typnamespace oid not null
 ├── typowner oid not null
 ├── typlen int not null
 ├── typbyval bool not null
 ├── typtype string not null
 ├── typcategory string not null
 ├── typispreferred bool not null
 ├── typisdefined bool not null
 ├── typdelim string not null
 ├── typrelid oid not null
 ├── typelem oid not null
 ├── typarray oid not null
 ├── typinput oid not null
 ├── typoutput oid not null
 ├── typreceive oid not null
 ├── typsend oid not null
 ├── typmodin oid not null
 ├── typmodout oid not null
 ├── typanalyze oid not null
 ├── typalign string not null
 ├── typstorage string not null
 ├── typnotnull bool not null
 ├── typbasetype oid not null
 ├── typtypmod int not null
 ├── typndims int not null
 ├── typcollation oid not null
 ├── typdefaultbin string
 ├── typdefault string
 ├── typacl string[]
 ├── INDEX primary
 │    └── oid oid not null
 └── INDEX pg_type_typname_nsp_index
      ├── typname string not null
      ├── typnamespace oid not null
      └── oid oid not null (storing)

opt
SELECT a.attname,
  format_type(a.atttypid, a.atttypmod),
  pg_get_expr(d.adbin, d.adrelid),
  a.attnotnull,
  a.atttypid,
  a.atttypmod,
  (SELECT c.collname
   FROM pg_collation c, pg_type t
   WHERE c.oid = a.attcollation
   AND t.oid = a.atttypid
   AND a.attcollation <> t.typcollation),
   col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"numbers"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
----
sort
 ├── columns: attname:2(string!null) format_type:65(string) pg_get_expr:66(string) attnotnull:13(bool!null) atttypid:3(oid!null) atttypmod:9(int!null) collname:67(string) comment:68(string)
 ├── fd: (3,9)-->(65)
 ├── ordering: +6
 └── project
      ├── columns: format_type:65(string) pg_get_expr:66(string) collname:67(string) comment:68(string) attname:2(string!null) atttypid:3(oid!null) attnum:6(int!null) atttypmod:9(int!null) attnotnull:13(bool!null)
      ├── fd: (3,9)-->(65)
      ├── right-join
      │    ├── columns: attrelid:1(oid!null) attname:2(string!null) atttypid:3(oid!null) attnum:6(int!null) atttypmod:9(int!null) attnotnull:13(bool!null) attisdropped:15(bool!null) attcollation:18(oid!null) adrelid:23(oid) adnum:24(int) adbin:25(string) pg_collation.oid:27(oid) pg_collation.collname:28(string) pg_type.oid:34(oid) typcollation:61(oid)
      │    ├── key: (1,6,23,24,27,34)
      │    ├── fd: ()-->(15), (1,6)-->(2,3,9,13,18), (1,2)-->(3,6,9,13,18), (23,24)-->(25), (27)-->(28), (34)-->(61)
      │    ├── inner-join
      │    │    ├── columns: pg_collation.oid:27(oid!null) pg_collation.collname:28(string!null) pg_type.oid:34(oid!null) typcollation:61(oid!null)
      │    │    ├── key: (27,34)
      │    │    ├── fd: (27)-->(28), (34)-->(61)
      │    │    ├── scan pg_collation@pg_collation_name_enc_nsp_index
      │    │    │    ├── columns: pg_collation.oid:27(oid!null) pg_collation.collname:28(string!null)
      │    │    │    ├── key: (27)
      │    │    │    └── fd: (27)-->(28)
      │    │    ├── scan pg_type
      │    │    │    ├── columns: pg_type.oid:34(oid!null) typcollation:61(oid!null)
      │    │    │    ├── key: (34)
      │    │    │    └── fd: (34)-->(61)
      │    │    └── filters [type=bool, outer=(27,61), constraints=(/27: (/NULL - ]; /61: (/NULL - ])]
      │    │         └── pg_collation.oid != typcollation [type=bool, outer=(27,61), constraints=(/27: (/NULL - ]; /61: (/NULL - ])]
      │    ├── left-join (lookup pg_attrdef)
      │    │    ├── columns: attrelid:1(oid!null) attname:2(string!null) atttypid:3(oid!null) attnum:6(int!null) atttypmod:9(int!null) attnotnull:13(bool!null) attisdropped:15(bool!null) attcollation:18(oid!null) adrelid:23(oid) adnum:24(int) adbin:25(string)
      │    │    ├── key columns: [22] = [22]
      │    │    ├── key: (1,6,23,24)
      │    │    ├── fd: ()-->(15), (1,6)-->(2,3,9,13,18), (1,2)-->(3,6,9,13,18), (23,24)-->(25)
      │    │    ├── left-join (lookup pg_attrdef@pg_attrdef_adrelid_adnum_index)
      │    │    │    ├── columns: attrelid:1(oid!null) attname:2(string!null) atttypid:3(oid!null) attnum:6(int!null) atttypmod:9(int!null) attnotnull:13(bool!null) attisdropped:15(bool!null) attcollation:18(oid!null) pg_attrdef.oid:22(oid) adrelid:23(oid) adnum:24(int)
      │    │    │    ├── key columns: [1 6] = [23 24]
      │    │    │    ├── key: (1,6,22)
      │    │    │    ├── fd: ()-->(15), (1,6)-->(2,3,9,13,18), (1,2)-->(3,6,9,13,18), (22)-->(23,24), (23,24)-->(22)
      │    │    │    ├── select
      │    │    │    │    ├── columns: attrelid:1(oid!null) attname:2(string!null) atttypid:3(oid!null) attnum:6(int!null) atttypmod:9(int!null) attnotnull:13(bool!null) attisdropped:15(bool!null) attcollation:18(oid!null)
      │    │    │    │    ├── key: (1,6)
      │    │    │    │    ├── fd: ()-->(15), (1,6)-->(2,3,9,13,18), (1,2)-->(3,6,9,13,18)
      │    │    │    │    ├── scan pg_attribute
      │    │    │    │    │    ├── columns: attrelid:1(oid!null) attname:2(string!null) atttypid:3(oid!null) attnum:6(int!null) atttypmod:9(int!null) attnotnull:13(bool!null) attisdropped:15(bool!null) attcollation:18(oid!null)
      │    │    │    │    │    ├── key: (1,6)
      │    │    │    │    │    └── fd: (1,6)-->(2,3,9,13,15,18), (1,2)-->(3,6,9,13,15,18)
      │    │    │    │    └── filters [type=bool, outer=(1,6,15), constraints=(/1: (/NULL - ]; /6: [/1 - ]; /15: [/false - /false]), fd=()-->(15)]
      │    │    │    │         ├── attrelid = '"numbers"'::REGCLASS [type=bool, outer=(1), constraints=(/1: (/NULL - ])]
      │    │    │    │         ├── attnum > 0 [type=bool, outer=(6), constraints=(/6: [/1 - ]; tight)]
      │    │    │    │         └── NOT attisdropped [type=bool, outer=(15), constraints=(/15: [/false - /false]; tight)]
      │    │    │    └── filters [type=bool, outer=(23,24), constraints=(/23: (/NULL - ]; /24: [/1 - ])]
      │    │    │         ├── adrelid = '"numbers"'::REGCLASS [type=bool, outer=(23), constraints=(/23: (/NULL - ])]
      │    │    │         └── adnum > 0 [type=bool, outer=(24), constraints=(/24: [/1 - ]; tight)]
      │    │    └── true [type=bool]
      │    └── filters [type=bool, outer=(3,18,27,34), constraints=(/3: (/NULL - ]; /18: (/NULL - ]; /27: (/NULL - ]; /34: (/NULL - ]), fd=(18)==(27), (27)==(18), (3)==(34), (34)==(3)]
      │         ├── pg_collation.oid = attcollation [type=bool, outer=(18,27), constraints=(/18: (/NULL - ]; /27: (/NULL - ])]
      │         └── pg_type.oid = atttypid [type=bool, outer=(3,34), constraints=(/3: (/NULL - ]; /34: (/NULL - ])]
      └── projections [outer=(1-3,6,9,13,23,25,28)]
           ├── format_type(atttypid, atttypmod) [type=string, outer=(3,9)]
           ├── pg_get_expr(adbin, adrelid) [type=string, outer=(23,25)]
           ├── variable: pg_collation.collname [type=string, outer=(28)]
           └── col_description(attrelid, attnum) [type=string, outer=(1,6)]
