Re: cast bytea to double precision[]

From: Mathieu Dubois <mathieu(dot)dubois(at)limsi(dot)fr>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: cast bytea to double precision[]
Date: 2011-07-24 19:03:36
Message-ID: 4E2C6C88.2040701@limsi.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have found a solution by myself for the conversion:
regexp_split_to_array(sig_vector, E',')::double precision[] (elements
are in fact separated by commas).

To convert my column I have used:
ALTER TABLE my_table ALTER sig_vector TO double precision[] USING
regexp_split_to_array(sig_vector, E',')::double precision[];

Is that correct?
Is it correct to pass the column name to regexp_split_to_array()?

Mathieu

On 07/24/2011 08:18 PM, Mathieu Dubois wrote:
> Hello,
>
> I have a column of type bytea which contains a vector encoded in a
> string (elements are separated by spaces).
> The problem is that it uses a lot of storage space.
>
> I would like to convert this column to an ARRAY column with ALTER
> COLUMN TYPE.
>
> If I understand correctly, I have to specify a function to cast bytea
> to double precision[]. Is it correct?
>
> If this is correct, how to do that?
>
> I use regexp_split_to_array to transform the bytea to a text[] but I
> can't figure out how to convert it to double precision[].
>
> I'm using postgres 8.4.
>
> Any idea?
>
> Thanks in advance,
> Mathieu
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Merlin Moncure 2011-07-25 15:54:33 Re: cast bytea to double precision[]
Previous Message Mathieu Dubois 2011-07-24 19:03:01 cast bytea to double precision[]