1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
SELECT
foo.relname as table,
a.attname as colonne,
pg_catalog.format_type(a.atttypid, a.atttypmod) as type,
(SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)
FROM pg_catalog.pg_attrdef d
WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef)
as valeur_par_defaut,
a.attnotnull as null_possible,
a.attnum as ordre
FROM pg_catalog.pg_attribute a,
(SELECT
c.oid as id,
c.relname as relname
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid)) foo
WHERE a.attrelid = foo.id
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY foo.relname, a.attnum; |