X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AA7AA9FA509 for ; Fri, 5 May 2006 12:04:58 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 55843-01 for ; Fri, 5 May 2006 12:04:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx3.surnet.cl (mx3.surnet.cl [216.155.73.182]) by postgresql.org (Postfix) with ESMTP id E61C79FA372 for ; Fri, 5 May 2006 12:04:40 -0300 (ADT) Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) by mx3.surnet.cl with ESMTP; 05 May 2006 11:04:39 -0400 X-IronPort-AV: i="4.04,172,1144036800"; d="scan'208"; a="10376998:sNHT19435916" Received: from alvh.no-ip.org (201.220.122.210) by cluster.surnet.cl (7.0.043) (authenticated as alvherre@surnet.cl) id 443B7DDC0035EEAF; Fri, 5 May 2006 11:04:39 -0400 Received: by alvh.no-ip.org (Postfix, from userid 1000) id E4B0EC31DD1; Fri, 5 May 2006 11:04:38 -0400 (CLT) Date: Fri, 5 May 2006 11:04:38 -0400 From: Alvaro Herrera To: Chris Hoover Cc: "pgsql-admin@postgresql.org" Subject: Re: Where to get column length Message-ID: <20060505150438.GA10554@surnet.cl> Mail-Followup-To: Chris Hoover , "pgsql-admin@postgresql.org" References: <1d219a6f0605050801n43054504j112a62f10c8fcc59@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1d219a6f0605050801n43054504j112a62f10c8fcc59@mail.gmail.com> User-Agent: Mutt/1.5.11+cvs20060403 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/56 X-Sequence-Number: 21588 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.