REPEAT is a string-building function that concatenates a given character expression to itself a defined number of times. Because it runs in the database engine it performs faster than application-side loops and guarantees identical collation and encoding as the source data. If the repeat count is zero or negative, an empty string is returned. When the count is NULL the entire result is NULL. Some dialects silently truncate the result if it exceeds the maximum string length for that data type. REPEAT is non-standard SQL but is widely implemented with identical or very similar behavior.
string_expression
(STRING) - The text to duplicate.repeat_count
(INT) - How many times to append string_expression to itself.REPLICATE, RPAD, CONCAT, LPAD, STRING_AGG
MySQL 3.23; adopted by PostgreSQL 8.3
The function returns an empty string, not NULL.
No. SQL Server offers the REPLICATE function, which is syntactically similar.
Yes. The function repeats the sequence of bytes. Ensure your collation and character set support the characters being repeated.
Yes. The output cannot exceed the maximum size of the underlying string type (e.g., 65,535 bytes in MySQL VARCHAR).