Re: Converting yes or no to one letter strings.

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Converting yes or no to one letter strings.
Date: 2019-06-05 14:20:15
Message-ID: 1ccaf983-78ab-28d9-23e3-a7bbd4e53344@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/4/19 7:27 PM, Ron wrote:
>
>
> On 6/4/19 7:19 PM, Adrian Klaver wrote:
>> On 6/4/19 3:29 PM, Lou wrote:
>>> Hi everyone,
>>>
>>> Is it possible to convert a boolean yes or no field to hold a one
>>> letter string? For example, the strings: 's' 'f' 'p' 'e'
>>>
>>> To start off, I just need to convert true to 's'. false will have to
>>> be manually changed to 'f' or 'p' or 'e' as appropriate.
>>
>> Why not an enum field?:
>>
>> https://www.postgresql.org/docs/11/datatype-enum.html
>
> I thought enum was Considered Harmful because of the difficulty in
> altering the enums?
>

The difficulty is removing a value:

https://www.postgresql.org/docs/11/sql-altertype.html

Otherwise I see equal difficulty in pretending that s, f, p and e are a
boolean choice.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Achilleas Mantzios 2019-06-05 14:38:39 Re: Postgresql-11 confusing situtation
Previous Message Prakash Ramakrishnan 2019-06-05 14:16:16 Re: pg_repack issue