== Why is this an issue?

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

[source,sql]
----
DECLARE
  var1 CHAR; -- Noncompliant

  var2 CHAR(42); -- Noncompliant

  var3 NCHAR; -- Noncompliant

  var4 NCHAR(42); -- Noncompliant
BEGIN
  NULL;
END;
/
----


=== Compliant solution

[source,sql]
----
DECLARE
  var1 VARCHAR2(42); 

  var2 VARCHAR2(42);

  var3 NVARCHAR2(42); 

  var4 NVARCHAR2(42);
BEGIN
  NULL;
END;
/
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Make "xxx" a "yyy".


'''
== Comments And Links
(visible only on this page)

=== on 28 Jan 2015, 19:12:10 Ann Campbell wrote:
\[~dinesh.bolkensteyn] this description is copied from Nemo. I think the wording may be off: \"``++CHAR++`` occupies *the same amount* of disk space and RAM than ``++VARCHAR2++``..."


Will you comment, please?

=== on 8 May 2015, 15:24:02 Dinesh Bolkensteyn wrote:
\[~ann.campbell.2] I understand the confusion. What is meant is that CHAR uses at least as many bytes as VARCHAR2.


Refer to AskTom for the better explanation ;) \https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:123212348063

=== on 11 May 2015, 13:29:32 Ann Campbell wrote:
please double-check my update [~dinesh.bolkensteyn]

=== on 11 May 2015, 14:10:31 Dinesh Bolkensteyn wrote:
Perfect

endif::env-github,rspecator-view[]
