repeat()

A function for repeating the input string

repeat() is a system function for generating multiple copies of the input string.

repeat() was added in PostgreSQL 7.0.

Usage

repeat ( string text, number integer ) → text

Change history

Examples

Basic execution example for repeat():

postgres=# SELECT repeat('foo', 4);
    repeat    
--------------
 foofoofoofoo
(1 row)

Specifying a zero or negative length returns an empty string:

postgres=# SELECT repeat('foo', 0);
 repeat 
--------
 
(1 row)

postgres=# SELECT repeat('foo', -1);
 repeat 
--------
 
(1 row)

Categories

String manipulation, System function