What is the difference between vsize and length functions?
select vsize(sysdate) FROM DUAL;
select length(sysdate) FROM DUAL;
Why it is showing different size in the above example?
Printable View
What is the difference between vsize and length functions?
select vsize(sysdate) FROM DUAL;
select length(sysdate) FROM DUAL;
Why it is showing different size in the above example?
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.
select
length('hello world'),
length(42),
length(9.0),
length(10.1),
length(-8),
length('')
from
dual;
In Oracle/PLSQL, the vsize function returns the number of bytes in the internal representation of an expression.
vsize('Tech on the net') would return 15
vsize('Tech on the net ') would return 16
vsize(null) would return <null>
vsize('') would return <null>
vsize(' ') would return 1
select
vsize('hello world'),
vsize(42),
vsize(9.0),
vsize(10.1),
vsize(-8),
vsize('')
from dual
while length returns the length of the pased string , vsize function returns the number of bytes used to store tha data.