Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1THFiY-00073x-HE for pgsql-admin@postgresql.org; Thu, 27 Sep 2012 15:09:34 +0000 Received: from hub.ringways.co.uk ([77.86.27.30] helo=mail.ringways.co.uk) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1THFiW-0007di-0r for pgsql-admin@postgresql.org; Thu, 27 Sep 2012 15:09:34 +0000 Received: from localhost ([127.0.0.1] helo=mail.ringways.co.uk) by mail.ringways.co.uk with esmtp (Exim 4.69) (envelope-from ) id 1THFiO-00053N-80; Thu, 27 Sep 2012 16:09:25 +0100 Received: from eddie.ringways.co.uk ([10.1.1.115] helo=eddie.ringways.co.uk) by mail.ringways.co.uk with ESMTP id qG9JOa9d09694; Thu, 27 Sep 2012 16:09:19 +0100 From: Gary Stainburn Organization: Ringways Garages Ltd To: pgsql-admin@postgresql.org Subject: Re: alter table alter column to resize a varchar Date: Thu, 27 Sep 2012 16:09:22 +0100 User-Agent: KMail/1.9.10 Cc: Craig James References: <201209271023.57710.gary.stainburn@ringways.co.uk> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201209271609.22833.gary.stainburn@ringways.co.uk> X-SpamTest-Envelope-From: gary.stainburn@ringways.co.uk X-SpamTest-Info: Profiles 20401 [Mar 31 2011] X-SpamTest-Method: none X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0285], KAS30/SDK/Release X-Anti-Virus: Kaspersky Mail Gateway, version: 5.6.28/RELEASE, bases: 20110331T110535 #5151353, check: 20120927 clean X-Spam-Score: -51.6 (---------------------------------------------------) X-Spam-Report: Spam detection software, running on the system "ollie.ringways.co.uk", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see Gary Stainburn for details. Content preview: On Thursday 27 September 2012 15:49:53 Craig James wrote: > On Thu, Sep 27, 2012 at 2:23 AM, Gary Stainburn > > wrote: > > Hi folks. > > > > I'm planning on extending a field in one of my main tables using: > > > > alter table stock alter column type varchar(255); > > Why not just do > > alter table stock alter column type text; > > That is, do you really need a limit? The VARCHAR type in Postgress is > just a TEXT type with an additional test to limit data to 255 > characters. It doesn't save space to limit the length. > [...] Content analysis details: (-51.6 points, 15.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -50 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 1.0 RING_SAFE RING_SAFE X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201210/4 X-Sequence-Number: 40120 On Thursday 27 September 2012 15:49:53 Craig James wrote: > On Thu, Sep 27, 2012 at 2:23 AM, Gary Stainburn > > wrote: > > Hi folks. > > > > I'm planning on extending a field in one of my main tables using: > > > > alter table stock alter column type varchar(255); > > Why not just do > > alter table stock alter column type text; > > That is, do you really need a limit? The VARCHAR type in Postgress is > just a TEXT type with an additional test to limit data to 255 > characters. It doesn't save space to limit the length. > I had an arbitary limit of 80 to keep the data managable within the applications. Now that limit is insufficient it may be worth re-evaluating the requirement. > > to extend it from the current varchar(80). My concern is that this table > > and this field is used in a number of views, and views of views. > > > > Are then any gotchas that I need to worry about or things I need to > > check, or will it just work? > > You can't alter a table that has dependent views. > > => alter table foo alter t type varchar(255); > ERROR: cannot alter type of a column used by a view or rule > DETAIL: rule _RETURN on view fooview depends on column "t" > > I keep scripts around to rebuild all of my views when necessary. If I > keep the scripts up to date, it make me much more willing to make a > schema change instead of putting it off until things are really messy. I have similar scripts for most of my scripts, but wasn't sure if I'd have to use them. Looks like I will, so I'll have to check that they're up-to-date. Thanks for the help Craig -- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringways.co.uk