pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
About changing type af a column
4+ messages / 4 participants
[nested] [flat]

* About changing type af a column
@ 2003-03-26 09:39  Marc Soler <msoler@el-valles.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Marc Soler @ 2003-03-26 09:39 UTC (permalink / raw)
  To: pgsql-admin

Hi all,

I need to change a column length.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: About changing type af a column
@ 2003-03-26 09:56  Victor Yegorov <viy@pirmabanka.lv>
  parent: Marc Soler <msoler@el-valles.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Victor Yegorov @ 2003-03-26 09:56 UTC (permalink / raw)
  To: Marc Soler <msoler@el-valles.com>; +Cc: pgsql-admin

* Marc Soler <msoler@el-valles.com> [26.03.2003 11:48]:
> Hi all,
> 
> I need to change a column length.
> 
> >From varchar(150) to varchar(250).
> 
> It's easy to change with an ALTER command? Or I need to create a new column,
> copy all data from the old column to the new one, then drop the old and
> rename the new.
> 
> If only exists the second solutions, the new column it will be created last
> one of the columns, then I must change all INSERT and UPDATE commands in my
> application.

How order of fields in the table can affect UPDATE statements?

About INSERTs - it's a good thing to specify all fields being inserted just
to prevent 'inconveniences' like you've mentioned.

> It's possible to create a column in a given position in the columns
> structure of a table?.

Yes. create a new table with same design except for the field you'd like to
change, than copy all data into new table, drop old one and rename new one.

> 
> Thanks in advance.

-- 

Victor Yegorov

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: About changing type af a column
@ 2003-03-26 13:13  A.Bhuvaneswaran <bhuvansql@myrealbox.com>
  parent: Marc Soler <msoler@el-valles.com>
  1 sibling, 0 replies; 4+ messages in thread

From: A.Bhuvaneswaran @ 2003-03-26 13:13 UTC (permalink / raw)
  To: pgsql-admin

> >From varchar(150) to varchar(250).

See pg_attribute.atttypmod. Searching the archive would have answered it.

regards,
bhuvaneswaran




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: About changing type af a column
@ 2003-03-26 14:39  Robert Treat <xzilla@users.sourceforge.net>
  parent: Victor Yegorov <viy@pirmabanka.lv>
  0 siblings, 0 replies; 4+ messages in thread

From: Robert Treat @ 2003-03-26 14:39 UTC (permalink / raw)
  To: Victor Yegorov <viy@pirmabanka.lv>; +Cc: Marc Soler <msoler@el-valles.com>; pgsql-admin

On Wed, 2003-03-26 at 04:56, Victor Yegorov wrote:
> * Marc Soler <msoler@el-valles.com> [26.03.2003 11:48]:
> > Hi all,
> > 
> > I need to change a column length.
> > 
> > >From varchar(150) to varchar(250).
> > 
> > It's easy to change with an ALTER command? Or I need to create a new
> column,
> > copy all data from the old column to the new one, then drop the old
> and
> > rename the new.
> > 
> > If only exists the second solutions, the new column it will be created
> last
> > one of the columns, then I must change all INSERT and UPDATE commands
> in my
> > application.
> 
> How order of fields in the table can affect UPDATE statements?
> 
> About INSERTs - it's a good thing to specify all fields being inserted
> just
> to prevent 'inconveniences' like you've mentioned.
> 

And actually relational theory states that column orders in tables is
irrelevant, so it's really a good idea to make sure you keep from
falling into this trap. This means referencing result set array by field
name rather than by number (ie. $arr[2] - which implies field position) 

> > It's possible to create a column in a given position in the columns
> > structure of a table?.
> 
> Yes. create a new table with same design except for the field you'd like
> to
> change, than copy all data into new table, drop old one and rename new
> one.
> 

funny part is I just answered this question on the -sql list yesterday,
so I happen to have the link handy to my archived post from several
months back that also answers this same question; check it out:

http://fts.postgresql.org/db/mw/msg.html?mid=1071582


Robert Treat




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-03-26 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-26 09:39 About changing type af a column Marc Soler <msoler@el-valles.com>
2003-03-26 09:56 ` Victor Yegorov <viy@pirmabanka.lv>
2003-03-26 14:39   ` Robert Treat <xzilla@users.sourceforge.net>
2003-03-26 13:13 ` A.Bhuvaneswaran <bhuvansql@myrealbox.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