SQL RPAD Function
SQL RPAD Function also called right pad is used to add characters or spaces to the right of a string. The syntax is
RPAD (CHARACTER SET)
Example 1:
The following SQL RPAD Function pads spaces to the right of each name, totaling 30 characters for each name regardless of length of name.
SELECT RPAD (first_name, 30) name FROM employee;
Output:
Example 2:
The following SQL RPAD Function is same as above except that it adds periods instead of spaces to the right.
SELECT RPAD (first_name, 30,'.') name FROM employee;
Output: