Bitwise AND (&)
The bitwise AND operator performs a bitwise logical AND operation between two operands.
The bitwise AND compares two bits and assigns a value equal to 1 to the result only if the values of both the bits are equal to 1. Otherwise, the bit in the result is set to 0. The AND operator, like all other bitwise operators, takes only numeric values as its operands.
Syntax
expression & expression
Expression is any valid expression containing the integer data type, which is transformed into a binary number for the bitwise operation.
Values Returned
In a bitwise AND operation involving operands of different integer data types, the argument of the smaller data type is converted to the larger data type or to the data type that is immediately larger than the larger of the two operands. For example, when performing an AND operation involving smallint and integer, the smallint expression is converted to integer.
If any of the operands involved in a bitwise AND operation is signed, then the resultant value is also signed.
Examples
The & operator can be used in conjunction with the IF function to find out whether a table is a system table or a user-defined table.
select Xf$Name, IF(Xf$Flags & 16 = 16, 'System table','User table') from X$File
When this statement is run against the Demodata sample database, the following results are returned:
X$File System table
X$Field System table
X$Index System table
Billing User table
Class User table
Room User table
Student User table
Tuition User table
Course User table
Department User table
Enrolls User table
Faculty User table
Person User table
X$Proc System table