pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedWhere to get column length
2+ messages / 2 participants
[nested] [flat]
* Where to get column length
@ 2006-05-05 15:01 Chris Hoover <revoohc@gmail.com>
2006-05-05 15:04 ` Re: Where to get column length Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 1 reply; 2+ messages in thread
From: Chris Hoover @ 2006-05-05 15:01 UTC (permalink / raw)
To: pgsql-admin
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).
Thanks,
Chris
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Where to get column length
2006-05-05 15:01 Where to get column length Chris Hoover <revoohc@gmail.com>
@ 2006-05-05 15:04 ` Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 0 replies; 2+ messages in thread
From: Alvaro Herrera @ 2006-05-05 15:04 UTC (permalink / raw)
To: Chris Hoover <revoohc@gmail.com>; +Cc: 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.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-05-05 15:04 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-05 15:01 Where to get column length Chris Hoover <revoohc@gmail.com>
2006-05-05 15:04 ` Alvaro Herrera <alvherre@commandprompt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox