trying to alter column

--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.<br>All t=
he values in the column are numbers but im getting this message<br><br>colu=
mn "xxxxxx" cannot be cast to type integer<br><br>Dropping and re=
adding the column is an option but downtime is very critical to us, so i wa=
s wondering<br>
if im doing something wrong and i can alter type somehow.<br>=A0<br><input =
id=3D"gwProxy" type=3D"hidden"><input onclick=3D"jsCall();" id=3D"jsProxy" =
type=3D"hidden"><div id=3D"refHTML"></div>

--002215048e77031644047187b9ee--
Aras Angelo [ Do, 20 August 2009 02:20 ] [ ID #2012776 ]

Re: trying to alter column

On Wed, Aug 19, 2009 at 6:20 PM, Aras Angelo<araskoktas [at] gmail.com> 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 [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Scott Marlowe [ Do, 20 August 2009 04:44 ] [ ID #2012777 ]
Datenbanken » gmane.comp.db.postgresql.admin » trying to alter column

Vorheriges Thema: help tuning query
Nächstes Thema: Background triggers?