Search Postgresql Archives

Re: alter column to inet get error.

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

 



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.clark@xxxxxxxxxxxxx
www.netwolves.com


--
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