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

SPACE

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

The SPACE() function repeats a space character a number of times. This is convenience for REPEAT, as available natively in SQL Server, for example.

SELECT 'a' || space(3) || 'b';
create.select(val("a").concat(space(3)).concat(val("b")).fetch();

The result being

+-------+
| space |
+-------+
| a   b |
+-------+

Dialect support

This example using jOOQ:

space(3)

Translates to the following dialect specific expressions:

-- ASE, CUBRID, DB2, H2, MARIADB, MYSQL, SQLSERVER, SYBASE, VERTICA
space(3)

-- FIREBIRD, HANA, INFORMIX, INGRES, ORACLE
rpad(' ', 3, ' ')

-- HSQLDB, POSTGRES, REDSHIFT
repeat(' ', 3)

-- SQLITE
' ' || substr("replace"(hex(zeroblob(3)), '00', ' '), 1, 3 - length(' '))

-- ACCESS, AURORA_MYSQL, AURORA_POSTGRES, COCKROACHDB, DERBY, MEMSQL, SQLDATAWAREHOUSE, TERADATA
/* UNSUPPORTED */

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

The jOOQ Logo