SPACE
Description
Generate a string consisting of a specified number of spaces.
Syntax
SPACE ( <len> )
Parameters
| Parameter | Description |
|---|---|
<len> | The number of spaces to generate |
Return Value
Returns a string consisting of the specified number of spaces. Special cases:
- If any Parameter is NULL, NULL will be returned.
- When
<len>is less than 0, an empty string is returned.
Examples
- Generate specified number of spaces
SELECT space(5);
+----------+
| space(5) |
+----------+
| |
+----------+
- Zero or negative number handling
SELECT space(0), space(-5);
+----------+-----------+
| space(0) | space(-5) |
+----------+-----------+
| | |
+----------+-----------+
- NULL value handling
SELECT space(NULL);
+-------------+
| space(NULL) |
+-------------+
| NULL |
+-------------+
- Use with other functions
SELECT CONCAT('Hello', space(3), 'World');
+------------------------------------+
| concat('Hello', space(3), 'World') |
+------------------------------------+
| Hello World |
+------------------------------------+
Keywords
SPACE