Altering column type from text to bytea

Started by Alexander Reichstadtabout 14 years ago3 messagesgeneral
Jump to latest

Hi,

when trying to change a text column to bytea I am getting the following error:
SQL error:

ERROR: column "comment" cannot be cast to type bytea

In statement:
ALTER TABLE "public"."persons" ALTER COLUMN "comment" TYPE bytea

I found that others had the same issue but I found no solution for it. I made a test-table and though it was empty meaning the column of concern had only NULL values I got the same error when trying to change that text column to type bytea.

Is it possible to change column types later on to bytea?

Thanks
Alex

In reply to: Alexander Reichstadt (#1)
Re: Altering column type from text to bytea

I just found a thread that outlines this issue and how to solve it here:
<http://archives.postgresql.org/pgsql-general/2005-12/msg01322.php&gt;

Thanks
Alex

Am 21.03.2012 um 20:56 schrieb Alexander Reichstadt:

Show quoted text

Hi,

when trying to change a text column to bytea I am getting the following error:
SQL error:

ERROR: column "comment" cannot be cast to type bytea

In statement:
ALTER TABLE "public"."persons" ALTER COLUMN "comment" TYPE bytea

I found that others had the same issue but I found no solution for it. I made a test-table and though it was empty meaning the column of concern had only NULL values I got the same error when trying to change that text column to type bytea.

Is it possible to change column types later on to bytea?

Thanks
Alex

#3Merlin Moncure
mmoncure@gmail.com
In reply to: Alexander Reichstadt (#1)
Re: Altering column type from text to bytea

On Wed, Mar 21, 2012 at 2:56 PM, Alexander Reichstadt <lxr@mac.com> wrote:

Hi,

when trying to change a text column to bytea I am getting the following
error:

*SQL error:*

ERROR: column "comment" cannot be cast to type bytea

*In statement:*
ALTER TABLE "public"."persons" ALTER COLUMN "comment" TYPE bytea

TRY ALTER TYPE ...USING using either direct cast or encode() function.

Please don't post emails in HTML format, thanks!

merlin