trying to alter column

trying to alter column

am 20.08.2009 02:20:45 von Aras Angelo

--002215048e77031644047187b9ee
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Im trying to alter a column type from character varying(8) to int.
All the values in the column are numbers but im getting this message

column "xxxxxx" cannot be cast to type integer

Dropping and readding the column is an option but downtime is very critical
to us, so i was wondering
if im doing something wrong and i can alter type somehow.

--002215048e77031644047187b9ee
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Im trying to alter a column type from character varying(8) to int.
All t=
he values in the column are numbers but im getting this message

colu=
mn "xxxxxx" cannot be cast to type integer

Dropping and re=
adding the column is an option but downtime is very critical to us, so i wa=
s wondering

if im doing something wrong and i can alter type somehow.
=A0
id=3D"gwProxy" type=3D"hidden"> type=3D"hidden">



--002215048e77031644047187b9ee--

Re: trying to alter column

am 20.08.2009 04:44:06 von Scott Marlowe

On Wed, Aug 19, 2009 at 6:20 PM, Aras Angelo wrote:
> Im trying to alter a column type from character varying(8) to int.
> All the values in the column are numbers but im getting this message
>
> column "xxxxxx" cannot be cast to type integer
>
> Dropping and readding the column is an option but downtime is very critical
> to us, so i was wondering
> if im doing something wrong and i can alter type somehow.

alter table xyz alter COLUMN i type int using i::int;

Note that this will fail if any of the entries in teh column i are not ints.

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