From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Accommodating alternative column values |
Date: | 2024-07-03 14:23:00 |
Message-ID: | CAKFQuwYmt-UmO_WaqZ-mhS+nBEm35kKy_CyCSu6Zqpam4ypxcQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jul 3, 2024 at 7:13 AM Rich Shepard <rshepard(at)appl-ecosys(dot)com>
wrote:
> On Wed, 3 Jul 2024, David G. Johnston wrote:
>
> > Yeah, the simply cast suggested will not work. You’d have to apply an
> > expression that turns the current contents into an array. The current
> > contents are not likely to be an array literal.
>
> David,
>
> No, it's not now an array.
>
> I thought that this expression would work, but it doesn't:
> bustrac=# alter table people alter column email set data type
> varchar(64)[] using email::varchar(64)[];
> RROR: malformed array literal: "frank(at)dmipx(dot)com"
> DETAIL: Array value must start with "{" or dimension information.
>
> If I correctly understand the error detail I'd need to change the contents
> of that column for all 1280 rows to enclose the contents in curly braces
> before I can convert the datatype to an array. Is that correct?
>
>
Assuming today there is only one email per row, no, see Torsten's reply.
You also wouldn't need to perform an update..."using ('{' || email ||
'}')::text[]" if just doing that...
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter J. Holzer | 2024-07-03 14:32:09 | Re: Accommodating alternative column values |
Previous Message | Torsten Förtsch | 2024-07-03 14:21:39 | Re: Accommodating alternative column values |