pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to chane  the type
4+ messages / 3 participants
[nested] [flat]

* how to chane  the type
@ 2001-12-05 13:12  tinar <tinarajraj@hotmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: tinar @ 2001-12-05 13:12 UTC (permalink / raw)
  To: pgsql-sql

i have created a table
userlist with fields username varchar(10)
now i want to change it to username varchar(30)
without dropping or recreating the table.
how do i do it?
tina

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

* Re: how to chane  the type
@ 2001-12-06 16:31  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: tinar <tinarajraj@hotmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Stephan Szabo @ 2001-12-06 16:31 UTC (permalink / raw)
  To: tinar <tinarajraj@hotmail.com>; +Cc: pgsql-sql


On Wed, 5 Dec 2001, tinar wrote:

> i have created a table
> userlist with fields username varchar(10)
> now i want to change it to username varchar(30)
> without dropping or recreating the table.
> how do i do it?

The best way is to recreate the table and rename
them around.  If you *REALLY* don't want to do
that and have a recent backup (yes, I'm serious),
you can muck with pg_attribute and change
atttypmod for the attribute in question
(from 14 to 34).





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

* Re: how to chane  the type
@ 2001-12-07 01:45  Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  parent: Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Christopher Kings-Lynne @ 2001-12-07 01:45 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; tinar <tinarajraj@hotmail.com>; +Cc: pgsql-sql

What's the essential problem with changing column types in postgres?  Is it
similar to the DROP COLUMN problem?

If the answer is that the table format only has allocated enough space per
row for the existing type, then how is it possible that Stephen's hack below
will not break things?

Chris

> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Stephan Szabo
> Sent: Friday, 7 December 2001 12:31 AM
> To: tinar
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] how to chane the type
>
>
>
> On Wed, 5 Dec 2001, tinar wrote:
>
> > i have created a table
> > userlist with fields username varchar(10)
> > now i want to change it to username varchar(30)
> > without dropping or recreating the table.
> > how do i do it?
>
> The best way is to recreate the table and rename
> them around.  If you *REALLY* don't want to do
> that and have a recent backup (yes, I'm serious),
> you can muck with pg_attribute and change
> atttypmod for the attribute in question
> (from 14 to 34).
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>




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

* Re: how to chane  the type
@ 2001-12-07 02:05  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  0 siblings, 0 replies; 4+ messages in thread

From: Stephan Szabo @ 2001-12-07 02:05 UTC (permalink / raw)
  To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>; +Cc: tinar <tinarajraj@hotmail.com>; pgsql-sql


On Fri, 7 Dec 2001, Christopher Kings-Lynne wrote:

> What's the essential problem with changing column types in postgres?  Is it
> similar to the DROP COLUMN problem?
>
> If the answer is that the table format only has allocated enough space per
> row for the existing type, then how is it possible that Stephen's hack below
> will not break things?

The hack below only works to change the max length of variable length
attributes and only upward.  I'd be very wary of trying to change the real
type of a value except between ones that are bitwise compatible (like I
think varchar and text are technically, but I'm not sure).

> > The best way is to recreate the table and rename
> > them around.  If you *REALLY* don't want to do
> > that and have a recent backup (yes, I'm serious),
> > you can muck with pg_attribute and change
> > atttypmod for the attribute in question
> > (from 14 to 34).




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


end of thread, other threads:[~2001-12-07 02:05 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-12-05 13:12 how to chane  the type tinar <tinarajraj@hotmail.com>
2001-12-06 16:31 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-12-07 01:45   ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2001-12-07 02:05     ` Stephan Szabo <sszabo@megazone23.bigpanda.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