Em 9 de outubro de 2017 17:18, Fabrízio de Royes Mello <
fabri...@timbira.com.br> escreveu:
>
>
> Em 9 de outubro de 2017 17:12, André Ormenese <aormen...@gmail.com>
escreveu:
> >
> > Boa tarde
> >
> > Preciso listar todos as colunas, de todas as tabelas, que tenham o
valor default definido. Independente do valor configurado.
> > Onde acho estas informações no catalogo do PostgreSQL 9.6.5 ?
> >
>
> André,
>
> Essa informação fica armazenada na tabela pg_attrdef [1] do catálogo.
>
> Att,
>
> [1] https://www.postgresql.org/docs/current/static/catalog-pg-attrdef.html
>

Apenas para ilustrar o que comentei no email anterior:

fabrizio=# CREATE TABLE foo (f1 SERIAL PRIMARY KEY, f2 TIMESTAMP, f3 TEXT
DEFAULT 'bar', f4 INTEGER);
CREATE TABLE
fabrizio=# SELECT a.attrelid, a.attname, b.adsrc FROM pg_attribute a JOIN
pg_attrdef b ON b.adrelid = a.attrelid AND b.adnum = a.attnum where
attrelid = 'foo'::regclass;
 attrelid | attname |              adsrc
----------+---------+---------------------------------
   102722 | f1      | nextval('foo_f1_seq'::regclass)
   102722 | f3      | 'bar'::text
(2 rows)


Att,

--
   Fabrízio de Royes Mello         Timbira - http://www.timbira.com.br/
   PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
_______________________________________________
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a