From: | Steve Clark <sclark(at)netwolves(dot)com> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: alter column to inet get error. |
Date: | 2010-09-03 14:37:32 |
Message-ID: | 4C81082C.3030305@netwolves.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 09/03/2010 09:38 AM, A. Kretschmer wrote:
> In response to Steve Clark :
>> Hello List,
>>
>> I want to change some columns in a database
>> that were originally created as char varying to
>> inet.
>>
>> When I try I get an error. Is there anyway to work
>> around this?
>>
>> See below for table definition.
>>
>> Table "public.kernel_gre"
>> Column | Type | Modifiers
>> -----------------+-----------------------+---------------
>> interface | character varying(15) | not null
>> source_ip | character varying(16) |
>> dest_ip | character varying(16) |
>> physical_ip | character varying(16) |
>> status | boolean | default false
>> physical_src_ip | character varying(16) |
>> tunnel_netmask | character varying(16) |
>> key | character varying(32) |
>> state | boolean | default false
>> broadcast | boolean | default false
>>
>> alter TABLE kernel_gre ALTER COLUMN source_ip TYPE inet;
>> ERROR: column "source_ip" cannot be cast to type "inet"
>
> Try this with explicet cast:
>
> test=# create table ip (ip text);
> CREATE TABLE
> Zeit: 247,763 ms
> test=*# copy ip from stdin;
> Geben Sie die zu kopierenden Daten ein, gefolgt von einem Zeilenende.
> Beenden Sie mit einem Backslash und einem Punkt alleine auf einer Zeile.
>>> 127.0.0.1
>>> \.
> Zeit: 5199,184 ms
> test=*# alter table ip alter column ip type inet using ip::inet;
> ALTER TABLE
> Zeit: 242,569 ms
> test=*# \d ip
> Tabelle »public.ip«
> Spalte | Typ | Attribute
> --------+------+-----------
> ip | inet |
>
> test=*#
>
>
> Regards, Andreas
Thanks guys, that seems to do the trick. Postgresql ROCKS!!!
--
Stephen Clark
NetWolves
Sr. Software Engineer III
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve(dot)clark(at)netwolves(dot)com
www.netwolves.com
From | Date | Subject | |
---|---|---|---|
Next Message | Devrim GÜNDÜZ | 2010-09-03 15:19:19 | Re: On-disk size of db increased after restore |
Previous Message | Daniel Wagner | 2010-09-03 13:42:36 | Problems (bug?) with the Postgres 8.4.4 optimizer, 2nd try |