New versions: Dev (3.14) | Latest (3.13) | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7 | 3.6 | 3.5 | 3.4 | 3.3

SHR

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The SR() function produces the bitwise shift right operation.

SELECT shr(16, 4);
create.select(shr(16, 4)).fetch();

The result being

+-----+
| shr |
+-----+
|   1 |
+-----+

Dialect support

This example using jOOQ:

shr(16, 4)

Translates to the following dialect specific expressions:

-- ASE, HSQLDB, SQLSERVER, SYBASE
(16 / CAST(power(2, 4) AS int))

-- CUBRID, MARIADB, MYSQL, POSTGRES, SQLITE
(16 >> 4)

-- DB2, INFORMIX
(16 / CAST(power(2, 4) AS integer))

-- FIREBIRD
bin_shr(16, 4)

-- H2
rshift(16, 4)

-- ORACLE
(16 / CAST(power(2, 4) AS number(10)))

-- ACCESS, AURORA_MYSQL, AURORA_POSTGRES, COCKROACHDB, DERBY, HANA, INGRES, MEMSQL, REDSHIFT, SQLDATAWAREHOUSE, TERADATA, 
-- VERTICA
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.14, see #10141)

The jOOQ Logo