RPAD Function - Oracle to MySQL Migration

In Oracle, the RPAD function returns the string right-padded to the specified number of characters. RPAD accepts 2 or 3 parameters in Oracle.

MySQL also provides the RPAD function, but it requires 3 parameters, so when converting Oracle RPAD with 2 parameters, you have to add ' ' as the 3rd parameter in MySQL.

Oracle:

  -- Pad string with blanks (default) 
  SELECT RPAD('abc', 7) FROM dual;
  #  abc    (4 blanks follow)
 
  -- Pad string with * 
  SELECT RPAD('abc', 7, '*') FROM dual;
  # abc****

MySQL:

  -- Pad string with blanks (3rd parameter must be specified) 
  SELECT RPAD('abc', 7, ' ');
  # abc    (4 blanks follow)
 
  -- Pad string with * 
  SELECT RPAD('abc', 7, '*');
  # abc****

For more information, see Oracle to MySQL Migration.