For fixed-length values, a CHAR field occupies the same amount of disk space as a VARCHAR2 field, but for variable-length
values CHAR fields use more storage space and make searching more difficult by right-padding values with whitespaces. Therefore
VARCHAR2 fields are preferred. Similarly, NCHAR should be replaced by NVARCHAR2.
Note that for 1-character fields, CHAR is naturally equivalent to VARCHAR2, but the latter is still preferred for
consistency.
Noncompliant code example
DECLARE
var1 CHAR; -- Noncompliant
var2 CHAR(42); -- Noncompliant
var3 NCHAR; -- Noncompliant
var4 NCHAR(42); -- Noncompliant
BEGIN
NULL;
END;
/
Compliant solution
DECLARE
var1 VARCHAR2(42);
var2 VARCHAR2(42);
var3 NVARCHAR2(42);
var4 NVARCHAR2(42);
BEGIN
NULL;
END;
/