Jump to: navigation, search

PostgreSQL RPAD

From w3cyberlearnings

Contents

Postgresql rpad

This function returns a string specifies by the right pad. When the LENGTH is shorter than the STR length, it will return based on the LENGTH, However if the LENGTH is longer than the STR's length, it will add the padstr to the return string after the STR. Check the example for detail.

Syntax rpad

  • string: a string input
  • length: character length to be pad
  • padstr: pad character
rpad(string,length,padstr)

Example 1

postgres=# SELECT rpad('great',10,'x');
    rpad    
------------
 greatxxxxx
(1 row)

Example 2


postgres=# SELECT rpad('100',10,'x');
    rpad    
------------
 100xxxxxxx
(1 row)

Related Links


Navigation
Web
SQL
MISC
References