Contents
right()
A function returning characters from the right of a string
right()
is a system function returning the specified number characters from the right of the provided string.
right()
was added in PostgreSQL 9.1.
Usage
right (string
text
,n
integer
) →text
If n
is negative, returns all but the first n
characters.
Change history
- PostgreSQL 9.1
- added (commit 49b27ab5)
Examples
Basic usage example for right()
:
postgres=# SELECT right('foobar', 3); right ------- bar (1 row)
Providing a negative value:
postgres=# SELECT right('foobarbaz', -3); right -------- barbaz (1 row)
Usage with a non-Latin character set:
postgres=# SELECT right('ほげほげ', 2); right ------- ほげ (1 row)
References
- PostgreSQL documentation: Other String Functions