Unable To Alter Data Type

From: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
To: "PostgreSQL (SQL)" <pgsql-sql(at)postgresql(dot)org>
Subject: Unable To Alter Data Type
Date: 2012-01-11 23:52:36
Message-ID: CAAQLLO5aXWj=Ss+9rKyohWcnb3Fnm2k_pAQu_pDfL=76VrbHzQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have an issue I can't figure out. I have the following TABLE:

tysql=# \d customers
Table "public.customers"
Column | Type | Modifiers
--------------+----------------+-----------
cust_id | character(10) | not null
cust_name | character(50) | not null
cust_address | character(50) |
cust_city | character(50) |
cust_state | character(5) |
cust_zip | character(10) |
cust_country | character(50) |
cust_contact | character(50) |
cust_email | character(255) |
Indexes:
"customers_pkey" PRIMARY KEY, btree (cust_id)
Referenced by:
TABLE "orders" CONSTRAINT "fk_orders_customers" FOREIGN KEY
(cust_id) REFERENCES customers(cust_id)

Now I'm attempting to ALTER the field 'cust_zip' TYPE from character
to integer however I'm getting the following error:

tysql=# ALTER TABLE customers ALTER COLUMN cust_zip TYPE bigint;
ERROR: column "cust_zip" cannot be cast to type bigint

I thought perhaps the stored data in the field conflicted with the
data type but I can't see why:

tysql=# SELECT cust_zip FROM customers;
cust_zip
------------
44444
43333
42222
88888
54545
32765
(6 rows)

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2012-01-12 00:13:55 Re: Unable To Alter Data Type
Previous Message Tom Lane 2012-01-11 16:14:58 Re: amount of join's and sequential access to the tables involved