Right padding the name of department : RPAD « Character String Functions « Oracle PL/SQL Tutorial






SQL>
SQL> create table departments
  2  ( deptno NUMBER(2)
  3  , dname  VARCHAR2(10)
  4  , location VARCHAR2(20)
  5  , mgr    NUMBER(4)
  6  ) ;

Table created.

SQL>
SQL> insert into departments values (10,'ACCOUNTING','NEW YORK' ,  2);

1 row created.

SQL> insert into departments values (20,'TRAINING',  'VANCOUVER',  3);

1 row created.

SQL> insert into departments values (30,'SALES',     'CHICAGO',    4);

1 row created.

SQL> insert into departments values (40,'HR',        'BOSTON',     5);

1 row created.

SQL>
SQL>
SQL> select dname, rpad(dname,6,'<')
  2  from   departments;

DNAME      RPAD(D
---------- ------
ACCOUNTING ACCOUN
TRAINING   TRAINI
SALES      SALES<
HR         HR<<<<

SQL>
SQL> drop table departments;

Table dropped.

SQL>








11.12.RPAD
11.12.1.Rpad
11.12.2.RPAD(x, width [, pad_string]) pads x with spaces to right to bring the total length of the string up to width characters
11.12.3.RPAD() with number column
11.12.4.Call RPAD function in PL/SQL
11.12.5.Right padding the name of department
11.12.6.Use both lpad() and rpad() to create a string
11.12.7.Use RPAD to format cursor variable
11.12.8.Use rpad to represent the level
11.12.9.Use rpad function with define column default value
11.12.10.Use rpad to format a report