SELECT
a.attname AS "field",
CASE t.typname
WHEN 'int8' THEN 'bigint'
WHEN 'int4' THEN 'integer'
WHEN 'int2' THEN 'smallint'
WHEN 'bpchar' THEN 'char'
WHEN 'float4' THEN 'float'
WHEN 'float8' THEN 'double'
ELSE t.typname
END AS "type",
a.attnotnull AS "notnull",
(p.contype = 'p') AS "primary",
pg_get_expr(d.adbin, d.adrelid) AS "default",
(
pg_get_serial_sequence(format('%I.%I', n.nspname, c.relname), a.attname) IS NOT NULL
OR a.attidentity <> ''
) AS "autoinc",
col_description(c.oid, a.attnum) AS "comment"
FROM
pg_attribute a
JOIN pg_class c ON a.attrelid = c.oid
JOIN pg_namespace n ON c.relnamespace = n.oid
JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
LEFT JOIN pg_constraint p ON a.attrelid = p.conrelid AND a.attnum = ANY(p.conkey) AND p.contype = 'p'
WHERE
c.relname = 'aijxc_pods'
AND n.nspname = 'public'
AND a.attnum > 0
AND NOT a.attisdropped
ORDER BY
a.attnum [ RunTime:0.004291s ]
SELECT COUNT(*) AS think_count FROM "aijxc_pods" [ RunTime:0.000624s ]
SELECT * FROM "aijxc_pods" ORDER BY "sort_order" ASC LIMIT 10 OFFSET 0 [ RunTime:0.000491s ]