Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

RPAD Function

Description

The RPAD function pads the right side of a string with a specific set of characters.

Syntax

RPAD( char1, n, [, char2 ] ) 

char1 :
character string
NULL

n :
integer
NULL

char2 :
character string
NULL

The RPAD function pads the right side of char1 with char2 until its length reaches n.

  • char1 : Specifies the string to pad characters to. If the length of char1 is greater than n, char1 is returned truncated to the length of n. If char1 is truncated at the first byte of a double-byte character set (e.g. Korean), the first byte is removed and then a space character is added. If the value is NULL, NULL is returned.
  • n : Specifies the length. If the value is NULL, NULL is returned.
  • char2 : Specifies the string to pad. The default value for char2 is a single space character (' '). If the value is NULL, NULL is returned.
Example
  • Example 1
  • The following is an example that pads the character X on the right of a string until the length of the string reaches 6.

SELECT RPAD('123', 6, 'X') FROM db_root;

  • Result : '123XXX'
  • Example 2
  • The following is an example that truncates a string to the length of 4 and returns the result.

SELECT RPAD('123456', 4, 'X') FROM db_root;

  • Result : '1234'