What is difference between varchar and varchar2

VARCHAR can store up to 2000 bytes of characters while VARCHAR2 can store up to 4000 bytes of characters.
   

If we declare datatype as VARCHAR then it will occupy space for NULL values, In case of VARCHAR2 datatype it will not occupy any space.

   

Name Varchar(10) - If you enter value less than 10, it utilize total 10 spaces.

Name Varchar2(10) - If you enter value less than 10 then remaining space is not utilize.

17 comments:

  1. Replies
    1. VARCHAR can store up to 2000 bytes of characters while VARCHAR2 can store up to 4000 bytes of characters.

      If we declare datatype as VARCHAR then it will occupy space for NULL values, In case of VARCHAR2 datatype it will not occupy any space.


      Name Varchar(10) - If you enter value less than 10, it utilize total 10 spaces.

      Name Varchar2(10) - If you enter value less than 10 then remaining space is not utilize.

      Delete
  2. thanks alot this is very helpful to me

    ReplyDelete
  3. all the difference you mentioned above are false

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. this is wrong answer.
      varchar:If you enter value less than 10, it utilize total 10 spaces.
      varchar2:If you enter value less than 10, it also utilize total 10 spaces.
      Both are similar,the main difference is SIZE.
      varchar size is 2000 byte
      varchar2 size is 4000 byte.

      Delete
    2. Yes Mohit...

      Above statement is suitable for char function.
      In char if you have entered 10 then it utilize total 10 spaces.

      Delete
  5. there is no difference in varchar and varchar2,oracle reserved varchar for future reference..

    ReplyDelete
  6. also,varchar datatype is oracle create and varchar2 is ANSI CREATED

    ReplyDelete
  7. In addition, varchar(10) is to reserve 10 characters for use, but varchar2(10) is to reserve 10 bytes length for use. If you have entered some UTF-8 code into the data table you'll see the difference. In this scenario, varchar2(10) can just hold 3 UTF-8 encoding characters while varchar(10) accomodates the whole 10.

    ReplyDelete