Re: Converting yes or no to one letter strings.

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Converting yes or no to one letter strings.
Дата
Msg-id CAKFQuwapnGz0fQP-ZE-coP190vv_NfFWJK+f6NyneFOqH-YP2g@mail.gmail.com
обсуждение исходный текст
Ответ на Converting yes or no to one letter strings.  (Lou <lou@dayspringpublisher.com>)
Список pgsql-general
On Tue, Jun 4, 2019 at 3:30 PM Lou <lou@dayspringpublisher.com> wrote:

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'

Something like the following should work:

ALTER TABLE ... ALTER COLUMN ... TYPE text USING (CASE WHEN ... THEN 's' ELSE 'f' END);


Though at this point you are probably better off creating a category table with a primary key and converting this column to be a foreign key.

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: "Ray O'Donnell"
Дата:
Сообщение: Re: Converting yes or no to one letter strings.
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Converting yes or no to one letter strings.