MariaDB SPACE() Function
In MariaDB, SPACE() is a built-in string function that returns a string consisting of a specified number of spaces.
MariaDB SPACE() Syntax
Here is the syntax of the MariaDB SPACE() function:
SPACE(count)
Parameters
- count
- 
Required. The number of space symbols that make up the string. 
If you provide the wrong number of parameters, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'SPACE'.
Return value
The MariaDB SPACE() function returns a string consisting of the specified number of spaces.
If the argument count is less than 1, the SPACE() function returns an empty string ''.
If the argument is NULL, the SPACE() function will return NULL.
MariaDB SPACE() Examples
Basic usage
The following statement returns a string consisting of 30 spaces using the MariaDB SPACE():
SELECT SPACE(30);
Output:
+--------------------------------+
| SPACE(30)                      |
+--------------------------------+
|                                |
+--------------------------------+Since spaces are invisible, you can use CHAR_LENGTH() to get the length of the string, as follows:
SELECT CHAR_LENGTH(SPACE(30));
Output:
+------------------------+
| CHAR_LENGTH(SPACE(30)) |
+------------------------+
|                     30 |
+------------------------+Empty string
If the argument count is less than 1, the SPACE() function returns an empty string ''.
SELECT LENGTH(SPACE(0)), LENGTH(SPACE(-1));
Output:
+------------------+-------------------+
| LENGTH(SPACE(0)) | LENGTH(SPACE(-1)) |
+------------------+-------------------+
|                0 |                 0 |
+------------------+-------------------+In this example, we used LENGTH() to get their byte length.
Conclusion
In MariaDB, SPACE() is a built-in string function that returns a string consisting of a specified number of spaces.