Sunday, 27 January 2013

Difference between length and vsize functions in oracle


length returns the length of the pased string , vsize function returns the number of bytes used to store tha data.

length returns the length of the string passed. If string is a number, it first converts the number into a string and then returns its length.As Oracle treats an empty string as null, the length of an empty string is also null.

if any non-english characters are there in a column, vsize function gives you howmany bytes used to store that value.

SQL> select length(sysdate) from dual;

LENGTH(SYSDATE)
---------------
              9
               
SQL> select vsize(sysdate) from dual;

VSIZE(SYSDATE)
--------------
             7

SQL> select sysdate from dual;

SYSDATE
---------
28-JAN-13