Re: How do i extract a certain bit from a bigint column

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How do i extract a certain bit from a bigint column
Дата
Msg-id 24064.1084366547@sss.pgh.pa.us
обсуждение исходный текст
Ответ на How do i extract a certain bit from a bigint column  (Mats Sjöberg <mats.sjoberg@cybernetics.se>)
Список pgsql-sql
Mats Sjöberg <mats.sjoberg@cybernetics.se> writes:
> What is the syntax to extract those bits?

At least in 7.4, you can do it the same way you'd do it in C:

regression=# select ((47::bigint) >> 3) & 1;?column?
----------       1
(1 row)
I'm not sure when the bigint >> and & operators got added, but \do would
tell you quickly enough if they're in your version.

Mind you that this is not going to be an especially fast solution, since
these are not indexable operators.  You might be better advised to
rethink your data representation.
        regards, tom lane


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

Предыдущее
От: Mike Rylander
Дата:
Сообщение: Re: How do i extract a certain bit from a bigint column
Следующее
От: "scott.marlowe"
Дата:
Сообщение: Re: working with schema