Re: Where to get column length

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Where to get column length
Дата
Msg-id 20060505150438.GA10554@surnet.cl
обсуждение исходный текст
Ответ на Where to get column length  ("Chris Hoover" <revoohc@gmail.com>)
Ответы Performance Slowly Decreasing As Database Grows  ("Lane Van Ingen" <lvaningen@esncc.com>)
Список pgsql-admin
Chris Hoover wrote:
> I know it is in the docs, but right now I can't see it.
>
> How do I pull the length of a specific varchar column?  I have just found a
> problem with our schema being out of sync on one specific column, and need
> to find out how many of our 200+ databases need to be fixed.
>
> Here is what I have so far:
> select *
> from pg_class, pg_attribute
> where pg_class.relkind = 'r' and
> pg_attribute.attrelid = pg_class.oid and
> pg_class.relname = 'mytable' and
> pg_attribute.attname = 'problem_column' and
> ???? != 256;  -- need to report anytime this column is not a varchar(256).

pg_attribute.atttypmod <> 256 + 4

(your 256 plus fixed 4 bytes of overhead for all variable length
attributes).

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

В списке pgsql-admin по дате отправления:

Предыдущее
От: "Chris Hoover"
Дата:
Сообщение: Where to get column length
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Best way to upgrade Postgresql 7.4.x to 8.1.x?