Difference Between Length and Vsize
It appears that the Oracle Functions Length ( ) and Vsize () return the same results, but practically there is a difference in their usage
For Example :
Select Length ('Have a Nice Day') , Vsize ( 'Have a Nice Day') From Dual;
Result : 15 , 15
Well the result is same for both , but let’s see another example :
Select Length (9.234), Vsize ( 9.234) from Dual;
Result : 5 , 4
More Examples :
Select Length ( Sysdate) , Vsize ( Sysdate) From Dual;
Result : 9 , 7 ( Current sysdate is '05-May-2013')
So we can see difference in the results, this is because Vsize returns the number of bytes used to store the internal representation in any datatype, whereas Length returns the length of the passed string. Length function takes the character arguments (Char, Varchar2, Nchar, NVarchar2, Clob or Nclob) , so even if you pass a non-character argument, the Length Function converts the data type implicitly into a string and then returns its length.
***Please leave a comment***
Difference Between Length and Vsize
It appears that the Oracle Functions Length ( ) and Vsize () return the same results, but practically there is a difference in their usage
For Example :
Select Length ('Have a Nice Day') , Vsize ( 'Have a Nice Day') From Dual;
Result : 15 , 15 Well the result is same for both , but let’s see another example :
Select Length (9.234), Vsize ( 9.234) from Dual;
Result : 5 , 4
More Examples :
Select Length ( Sysdate) , Vsize ( Sysdate) From Dual;
Result : 9 , 7 ( Current sysdate is '05-May-2013')
So we can see difference in the results, this is because Vsize returns the number of bytes used to store the internal representation in any datatype, whereas Length returns the length of the passed string. Length function takes the character arguments (Char, Varchar2, Nchar, NVarchar2, Clob or Nclob) , so even if you pass a non-character argument, the Length Function converts the data type implicitly into a string and then returns its length.
***Please leave a comment***
Well explained. Thanks Kalyan.
ReplyDelete