Re: Listar todos as colunas com valor default definido

André Ormenese <[email protected]>
Newsgroups gmane.comp.db.postgresql.brasil
Message-ID <CAKKKy7+JijagqWoAFpsh09NCNz-g9LVv7ACg6eNocLtGY_VewA__1795.25163625858$1507581141$gmane$org@mail.gmail.com>
Obrigado Fabrízio e Manuel !!!

Pela dica do Fabrízio já cheguei no resultado esperado !!

Att
André


*Minhas figuras favoritas do folclore brasileiro são a democracia e o
estado laico.*

2017-10-09 17:23 GMT-03:00 Manuel Garcia <[email protected]>:

> Boa tarde eu fiz algo parecido mais com a seguinte consulta  espero te
> ajude.
>
> SELECT *
> FROM information_schema.columns AS schema_public
> WHERE schema_public.table_schema = 'public' AND
> schema_public.column_default is not null AND  schema_public.column_default
> not like 'nextval%'
>
>
>
> 2017-10-09 17:21 GMT-03:00 Fabrízio de Royes Mello <
> fabrizio-hNsCO/[email protected]>:
>
>> Em 9 de outubro de 2017 17:18, Fabrízio de Royes Mello <
>> fabrizio-hNsCO/[email protected]> escreveu:
>> >
>> >
>> > Em 9 de outubro de 2017 17:12, André Ormenese <[email protected]>
>> 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-b/[email protected]
>> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>>
>
>
>
> --
>            Manuel Alejandro Garcia Mellado
> Ingeniero Ejecución en Informática e computación
> Concepcion - Chile VIII Region del Bio - Bio
>
>
> _______________________________________________
> pgbr-geral mailing list
> pgbr-geral-b/[email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>

_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.