Search Postgresql Archives

Re: alter column to inet get error.

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

 



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
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux