Re: change varchar(10) to varchar()

From: Gnanavel S <s(dot)gnanavel(at)gmail(dot)com>
To: "operationsengineer1(at)yahoo(dot)com" <operationsengineer1(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: change varchar(10) to varchar()
Date: 2005-08-05 04:04:01
Message-ID: eec3b03c050804210423e738a8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

In 8.0 and above, this can be done by using
ALTER TABLE table_name alter column column_name type new_data_type

for pre 8.0 releases
create an additional column(with different name) with the desired data
type(higher data type)
update the column with the values of the old column
remove the old column.
Finally rename the new column to old column.

On 8/4/05, operationsengineer1(at)yahoo(dot)com <operationsengineer1(at)yahoo(dot)com>
wrote:
>
> is there a sql command to change a field data type
> from varchar(10) to varchar()?
>
> i tried to do this in pgadmin3, but when i deleted the
> length (maximum characters) attribute, the OK button
> stayed grayed out and inactive. as an aside, the OK
> button becomes active when the length attribute is
> changed... but turns gray when it is deleted
> altogether.
>
> i don't want to put any arbitrary constraints on my
> s/n field - especially since there is no performance
> benefit in doing so per the manual.
>
> tia...
>
> ps - i can delete and recreate the table with no
> problems - but i would prefer to learn something for
> future reference, if possible.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>

--
with regards,
S.Gnanavel
Satyam Computer Services Ltd.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-08-05 04:58:56 Re: change varchar(10) to varchar()
Previous Message Michael Fuhr 2005-08-04 21:35:57 Re: Handling Daylight Savings