pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@commandprompt.com>
To: Chris Hoover <revoohc@gmail.com>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: Where to get column length
Date: Fri, 5 May 2006 11:04:38 -0400
Message-ID: <20060505150438.GA10554@surnet.cl> (raw)
In-Reply-To: <1d219a6f0605050801n43054504j112a62f10c8fcc59@mail.gmail.com>
References: <1d219a6f0605050801n43054504j112a62f10c8fcc59@mail.gmail.com>

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.



view thread (2+ messages)

Message-ID: <20060505150438.GA10554@surnet.cl>
Permalink:  ../20060505150438.GA10554@surnet.cl/
Also on:    postgresql.org/message-id/20060505150438.GA10554@surnet.cl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: alvherre@commandprompt.com, revoohc@gmail.com
  Subject: Re: Where to get column length
  In-Reply-To: <20060505150438.GA10554@surnet.cl>
  References: <1d219a6f0605050801n43054504j112a62f10c8fcc59@mail.gmail.com> <20060505150438.GA10554@surnet.cl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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