diff b/n char and varcha2
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: diff b/n char and varcha2

  1. #1
    Join Date
    Nov 2001
    Location
    Singapore
    Posts
    182

    diff b/n char and varcha2

    Hi,
    Could any one briefly explain me what is the diff b/n char and varchar2 everyone says char is fixed length varchar2 is valiable length i need meore explanation.

    sql>create table a(name vachar2(20),grade char(3));
    table created;
    Explain me how the memory is allocated/used for the above columns

    sql>insert into a values('Ganga','A');
    one row created;
    Though i have declared varchar2(10),char(3) entered only 5 char(string) name and one char grade . Now how the memory is used for above one row insertion.


    Tks in advance

    Gangu
    J Gangadhar

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,331
    well basically the varchar2 will use one byte per character so you will use 5 bytes there

    The char(3) will use 3 bytes, whether you insert A or ABC - same storage used for both. So there is no need to use char at all really as it is literally a waste of space

  3. #3
    Join Date
    Nov 2001
    Location
    Singapore
    Posts
    182
    Tks lot davey23uk
    What i thinking was when we specify varchar2(20) it allocates 20 bytes for the column consumes all bytes whether we insert 20 char or less than 20 chars

    once again Tks lot
    J Gangadhar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width