pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Chris Faulkner <chrisf@oramap.com>
To: Pgsql-Sql <pgsql-sql@postgresql.org>
Subject: create new field
Date: Mon, 6 Oct 2003 17:35:11 +0100
Message-ID: <DGENKIKMJILAAKJGFHKFAEHPCIAA.chrisf@oramap.com> (raw)
Hello
I would like to change the type of a column. At the moment, it is varchar(4)
but I would like it to be int. All values in the field at the moment are
actually integer.
I tried a way I had seen in the archives - it foes along the lines of adding
a column, using update, drop the old column and rename the new one.
alter table tab add column new_col int4;
update tab set new_col = "OLD_COL";
ERROR: column "new_col" is of type integer but expression is of type
characte
r
You will need to rewrite or cast the expression
OK - so I tried casting.
template1=# update tab set new_col = "OLD_COL"::int4;
ERROR: Cannot cast type character to integer
I understand this - some tables might have characters in the varchar but how
to get around it in my case ? I know that my character field has only
integers in it ?
Thanks
Chris
view thread (3+ messages) latest in thread
Message-ID: <DGENKIKMJILAAKJGFHKFAEHPCIAA.chrisf@oramap.com> Permalink: ../DGENKIKMJILAAKJGFHKFAEHPCIAA.chrisf@oramap.com/ Also on: postgresql.org/message-id/DGENKIKMJILAAKJGFHKFAEHPCIAA.chrisf@oramap.com ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients using the --to and --cc options: reply via email To: pgsql-sql@postgresql.org Cc: chrisf@oramap.com Subject: Re: create new field In-Reply-To: <DGENKIKMJILAAKJGFHKFAEHPCIAA.chrisf@oramap.com> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox