Easy learning with example program codes

What is the difference between CHAR and VARCHAR2 datatype in SQL?

Char type refers to fixed size datatype. So if we declare it with 10 bytes, then it always stores 10 bytes in the database and it doesn’t matter whether we store any text or just empty 10 bytes

Varchar2 represents a datatype of variable size, it’s size depends on how many bytes you are actually going to store in the database. The number we specify is just the maximum number of bytes that can be stored.  Minimum is 1 byte.

We should use CHAR when we know the exact length of the value in advance, database can then manipulate with it better and faster since it knows the exact length. Otherwise use VARCHAR2.


username VARCHAR2(255),
zip_code CHAR(6) //Fixed size zip code

Related topics

Posted in SQL   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki