RPAD and LPAD in SQL

For Complete YouTube Video: Click Here

In this class, we will understand RPAD and LPAD in SQL.

We have already discussed the concepts of UPPER LOWER and INITCAP.

RPAD and LPAD in SQL

RPAD and LPAD are very similar functions.

LPAD and RPAD are used to pad characters after the values in the column.

RPAD in SQL

RPAD allows to PAD the right side of a column with any set of characters.

RPAD(String, Size, ‘set’]);

To understand this consider the table below.

RPAD and LPAD in SQL 1
RPAD and LPAD 1

The query below is the use RPAD.

The output of the query is as shown below.

RPAD and LPAD in SQL 2
RPAD and LPAD 2

LPAD in SQL

LPAD allows to PAD the left side of a column with any set of characters.

To understand this consider the table below.

The query below is the use LPAD.

The output of the query is as shown below.

RPAD and LPAD in SQL 3
RPAD and LPAD 3