MariaDB SPACE() Function
Updated on
MariaDB SPACE(N) returns a string containing N space characters. If N is NULL, the function returns NULL.
Syntax
SPACE(N)
N is the requested number of spaces. If it is zero or negative, SPACE() returns an empty string. To repeat another character or substring, use REPEAT().
Make the spaces visible
Spaces are difficult to see in a result grid. QUOTE() surrounds the result with quotes, and CHAR_LENGTH() reports the number of characters:
SELECT QUOTE(SPACE(6)) AS six_spaces,
CHAR_LENGTH(SPACE(6)) AS character_count;
QUOTE(SPACE(6)) = ' '
CHAR_LENGTH(SPACE(6)) = 6Zero, negative, and NULL counts
Zero or negative counts produce an empty string; a NULL argument produces NULL:
SELECT LENGTH(SPACE(0)) AS zero_count,
LENGTH(SPACE(-1)) AS negative_count,
SPACE(NULL) AS null_count;
zero_count = 0
negative_count = 0
null_count = NULLFurther reading
- MariaDB
SPACE()reference - MariaDB
REPEAT()reference