Oracle PL/SQL - Differences Between CHAR and VARCHAR2 Data Types

Introduction

CHAR and VARCHAR2 data types differ in:

  • Predefined Subtypes
  • Blank-Padding
  • Value Comparisons

The CHAR data type has one predefined subtype in both PL/SQL and SQL:CHARACTER.

The VARCHAR2 data type has one predefined subtype in both PL/SQL and SQL:VARCHAR, and an additional predefined subtype in PL/SQL:STRING.

Each subtype has the same range of values as its base type.

For CHAR, PL/SQL blank-pads the value to the maximum size.

Information about trailing blanks in the original value is lost.

For VARCHAR2, PL/SQL neither blank-pads the value nor strips trailing blanks.

Character values are assigned intact, and no information is lost.

Related Topic