Поиск
Список
Период
Сортировка
Искать

От:
Mukund Pate <patemukund@yahoo.com>
Дата:

hello,

how to modify the datatype of column in a table?

i have created table with one coulmn datatype is varchar(200) so i  would like to change to text datatype

thanks in advance

mukund



Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Re:

От:
Robert Treat <xzilla@users.sourceforge.net>
Дата:
On Thu, 2002-12-12 at 01:39, Mukund Pate wrote:
> hello,
> 
> how to modify the datatype of column in a table?
> 
> i have created table with one coulmn datatype is varchar(200) so i
> would like to change to text datatype
> 

You will need to recreate the table. 

Robert Treat


Re:

От:
Robert Treat <xzilla@users.sourceforge.net>
Дата:
On Thu, 2002-12-12 at 14:50, Robert Treat wrote:
> On Thu, 2002-12-12 at 01:39, Mukund Pate wrote:
> > hello,
> > 
> > how to modify the datatype of column in a table?
> > 
> > i have created table with one coulmn datatype is varchar(200) so i
> > would like to change to text datatype
> > 
> 
> You will need to recreate the table. 
> 
> Robert Treat

Actually, I should point out that you can do an alter table add col2
text, update table set col2 = col1, update col1 set = NULL, rename col1
coldepricated, rename col2 to col1. If your in 7.3 you can drop
coldepricated too. Sorry for the weak answer before.

Robert Treat


Re: Untitled

От:
Erwin Moller <erwin@_no_spam_dexus.nl>
Дата:
Mukund Pate wrote:

> --0-762086988-1039675154=:50830
> Content-Type: text/plain; charset=us-ascii
> 
> 
> hello,
> 
> how to modify the datatype of column in a table?
> 
> i have created table with one coulmn datatype is varchar(200) so i  would
> like to change to text datatype
> 

Hi,

Please take the time to fill in a subject next time you post.

To your question:
You cannot change the datatype in an existing table.
If you are using Postgres 7.3 (next time you post please give us some 
backgroundinformation like your Postgresversion and OS) you can add a 
column of the texttype to your table and give a simple SQL-command to 
populate it. (UPDATE tblyourtable SET newcolumn=oldcolumn)

Then drop the old column.

If you are using triggers (Foreign keys for example) or indexes on the 
column, you better think it over first and recreate them afterwards.

Regards,
Erwin
> thanks in advance
> 
> mukund
> 
> 
> 
FAQ