What is the difference between Varchar and Varchar2 data types(Basic SQL Interview questions)


Difference between Varchar and Varchar2 Data types:


> Varchar stores up to 2000 bytes of Alpha numeric characters.

> Varchar2 Stores up to 4000 bytes of Alpha numeric characters.

> If we declare/create column with varchar data type and  the passed value is less than Actual Size of column size then oracle system by default appends the spaces with NULL value .

> And the same way if we create a column with Varchar2 data type then oracle system by default won't append/allocate the spaces. So this will save memory.

Example : 

 EmployeeName Varchar(10) --> If we enter the name less than 10 characters, Then system will append/occupy the remaining with space. So we can't use the remaining memory.

EmployeeName Varchar2(10) -->  If we enter/Pass the name value less than 10 characters, Then system won't append/allocate space. So system can utilize the remaining memory .

> By default system will allocate 1 Byte memory to Varchar and Varchar2.

> Varchar is of ANSI( American national standard institution ) SQL standard and where as Varchar2 is of ORACLE standard.

> In a simple way, We can say Varchar2 is the updated version of varchar.


                                                                Thank You.




Comments

Post a Comment