База данных: MySQL


Shifts a longlong (BIGINT) number or binary string to the left.

The result type depends on whether the bit argument is evaluated as a
binary string or number:

o Binary-string evaluation occurs when the bit argument has a binary
string type, and is not a hexadecimal literal, bit literal, or NULL
literal. Numeric evaluation occurs otherwise, with argument
conversion to an unsigned 64-bit integer as necessary.

o Binary-string evaluation produces a binary string of the same length
as the bit argument. Numeric evaluation produces an unsigned 64-bit

Bits shifted off the end of the value are lost without warning,
regardless of the argument type. In particular, if the shift count is
greater or equal to the number of bits in the bit argument, all bits in
the result are 0.

For more information, see the introductory discussion in this section.

URL: https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html


mysql> SELECT 1 << 2;
-> 4
mysql> SELECT HEX(_binary X'00FF00FF00FF' << 8);
-> 'FF00FF00FF00'