Re: type of a field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Short answer: You can't
Long answer: There are many workarounds.

Workaround 1: 
dump the table with pg_dump dbase -t tablename
edit dump file to change table definition
drop and reload table.

Workaround 2:
Let's say you wanna change a varchar to a text type.

Original table t1:
col | type
----------
nam | varchar(32)
id  | int4

select nam::text, id into t2 from t1;
drop table t1;
alter table t2 rename to t1;

You can do the above in a transaction if you are on a live database.  I'd 
back up the data first just to be sure.

On Tue, 7 May 2002, ameen eetemadi wrote:

> I want to change the type of a field in postgres .
> How can I do it ?
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux