REPEAT¶
The REPEAT
function repeats an input string expression as many times as specified.
Syntax¶
REPEAT('expr', n)
Arguments¶
Parameter |
Description |
---|---|
|
A |
|
An |
Return¶
Returns a
TEXT
string.When
n
= 0, and empty string is returned.When
n
< 0, an error is thrown.
Examples¶
For these example, consider the following table:
CREATE TABLE customer(customername TEXT);
INSERT INTO customer VALUES
('Alfreds Futterkiste'),
('Ana Trujillo Emparedados y helados'),
('Antonio Moreno Taquería'),
('Around the Horn');
Repeating Content of a Table Column¶
SELECT REPEAT(customername, 2) FROM customer;
repeat
--------------------------------------------------------------------
Alfreds FutterkisteAlfreds Futterkiste
Ana Trujillo Emparedados y heladosAna Trujillo Emparedados y helados
Antonio Moreno TaqueríaAntonio Moreno Taquería
Around the HornAround the Horn
Repeating a String¶
SELECT REPEAT('abc', 3);
repeat
---------
abcabcabc
Repeating a String 0 Times¶
SELECT REPEAT('abc', 0);
repeat
------
Repeating an Empty String¶
SELECT REPEAT('', 3);
repeat
------