Oracle BITAND function (bitwise AND)
Oracle uses the BITAND function heavily (over 1000 times in the catalog.sql script alone as of 10.2.0.4). It’s used to determine whether a particular bit is set or not.
Here’s a link to 11gR1 documentation on the BITAND function. The function takes 2 arguments and performs these basic steps:
- Converts the 2 arguements to binary (n-bit two’s complement binary integer value)
- Performs a standard bitwise AND operation on the two strings
- Converts the binary result back to decimal
So what’s a standard bitwise AND operation actually do?
Well it basically does a logical AND of two bit strings. If the values in any position are both 1′s, then the result will have a 1 in that position, otherwise the result will have a 0 in that position. Here’s a link to the Wikipedia entry on bitwise operations in case you want more information.
Here’s an example:
0101 AND 1001 = 0001 |




