• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql command doubt

 
RabiDas Sharma
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

1>please explain what is the difference between
varchar2 and varchar??

2>what is the difference between
Number and Number(2)?


please tell me websites good at explaining these things.
 
Gourav Gupta
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between varchar and varchar2 is :
1. VARCHAR is going to be replaced by VARCHAR2 in next version. So, Oracle suggests the use VARCHAR2 instead of VARCHAR while declaring datatype.

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

3. 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.

Difference between Number and Number(2) is :
Number means it will hold any value (For example 3, 400, 4.2323 ) but Number(2) means it will hold with 2 digit decimal value (For example 4.23 only ) .
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your first point about VARCHAR and VARCHAR2 is correct - Oracle suggests to use VARCHAR2, not VARCHAR, "to avoid possible changes in behavior" (source).

But the two other points are false - in the last few releases of Oracle database, VARCHAR and VARCHAR2 are completely identical.

The difference between NUMBER and NUMBER(2) is not right either: NUMBER(2) is identical to NUMBER(2,0), which means two digits of precision and zero decimal digits. NUMBER(2) will therefore accept numbers between -99 and +99, and will round the input to zero decimal digits. All the details about the NUMBER datatype in Oracle can be found at the same page as above.

And regarding the last OP's question: I can wholeheartedly suggest reading the entire Concepts guide to anyone who wants to use the Oracle database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic