![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Sybase 11.5.1 I have a table with around 150 columns, all of which are 1/0 (ie on/off) flags. I want to save space and come up with something that users can query easily. Is this a good candidate for a bitwise operator? What is the best implementation of this - it seems like I could get all my flags in one int column doing it this way. Is it possible to then put a view over the top for the users to read? If so, does anyone have a simple example of this that I could expand on? Thank you for any help Tom |
#3
| |||
| |||
|
|
Hi, Sybase 11.5.1 I have a table with around 150 columns, all of which are 1/0 (ie on/off) flags. I want to save space and come up with something that users can query easily. Is this a good candidate for a bitwise operator? What is the best implementation of this - it seems like I could get all my flags in one int column doing it this way. Is it possible to then put a view over the top for the users to read? If so, does anyone have a simple example of this that I could expand on? Thank you for any help Tom |
#4
| |||
| |||
|
|
Hi, I think you could simply use integer column instead and store boolean values on bits. The only additional thing you should do is to write database functions to read and set specific bits in this integer field. For example: f_set_bit(current_value, bit_no) f_read_bit(current_value, bit_no) So SELECT can look like: Reading 3rd bit from field 'field_name' SELECT f_set_bit(field_name, 3) FROM table_name WHERE... and UPDATE (modyfing 3rd bit in field 'field_name'): UPDATE table_name SET field_name = f_set_bit(field_name, 3) WHERE... Of course this solution has many disadvantages. The main is that all WHERE instructions which include f_read_bit function will be much slower. No indexes can be set on a specified bits as well. Maciek |
#5
| |||
| |||
|
|
Hi, Sybase 11.5.1 I have a table with around 150 columns, all of which are 1/0 (ie on/off) flags. I want to save space and come up with something that users can query easily. Is this a good candidate for a bitwise operator? What is the best implementation of this - it seems like I could get all my flags in one int column doing it this way. Is it possible to then put a view over the top for the users to read? If so, does anyone have a simple example of this that I could expand on? Thank you for any help Tom |
#6
| |||
| |||
|
|
I have a table with around 150 columns, all of which are 1/0 (ie on/off) flags. |
#7
| |||
| |||
|
|
I have a table with around 150 columns, all of which are 1/0 (ie on/off) flags. I have a 1000 word article about the use of BIT columns sitting at DBAzine right now. Basically, I attack this as a non-relational, proprietary, hardware-dependent throwback to the days of punch cards. My recommendation is to sit down and design a meaningful encoding scheme for the data. |
#8
| |||
| |||
|
|
I have a table with around 150 columns, all of which are 1/0 (ie on/off) flags. I have a 1000 word article about the use of BIT columns sitting at DBAzine right now. Basically, I attack this as a non-relational, proprietary, hardware-dependent throwback to the days of punch cards. My recommendation is to sit down and design a meaningful encoding scheme for the data. |
#9
| |||
| |||
|
|
I had a look on DBAzine and couln't find it. Can you provide a link please? |
#10
| |||||||
| |||||||
|
|
The computer, after all, is based on "bits". |
|
All hardware supports bits. |
|
All operating systems support bits. |
|
The question is, does the database software expose them? |
|
If you want to pack your bits into integers yourself, and then encode them |

|
My guess, is that you are an Oracle drone .. |
Considering I have|
"Punch cards" support only bytes--80 of them per card. |
![]() |
| Thread Tools | |
| Display Modes | |
| |