Results 1 to 3 of 3

Thread: Vsize and length difference

  1. #1
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Vsize and length difference

    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?

    Last edited by krishnaindia2007; 12-08-2007 at 05:32 AM.

  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Vsize and length difference

    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
    vsize('') would return
    vsize(' ') would return 1

    select
    vsize('hello world'),
    vsize(42),
    vsize(9.0),
    vsize(10.1),
    vsize(-8),
    vsize('')
    from dual


  3. #3
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Vsize and length difference

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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact