What is difference between varchar and varchar2

Showing Answers 1 - 64 of 64 Answers

mitto

  • Mar 12th, 2006
 

can i get an example for the two.

  Was this answer useful?  Yes

niranjan rampure

  • Mar 12th, 2006
 

varchar stands for variable character length type

both are ideally same . varchar2 is supported by Oracle

varchar is supported by MSSQL server 2000

krishna

  • Mar 15th, 2006
 

Varchar and Varchar2 are both same except for varchar2 supports upto 2000 char

  Was this answer useful?  Yes

ramadass

  • Mar 21st, 2006
 

hi... in oracle name varchar(10)-in this declaration it allocate 10 spaces in memory.if suppose ur using 4 charecter the extra space wasted. name varcher2(10)-in this declaration the extra space used by other operations automatically.

Ankur

  • Apr 10th, 2006
 

when varchar means fixed leght character then what is the diff between char and varchar

shambhukjha

  • Apr 20th, 2006
 

Above said answer was wrong

. Actually both varchar and varchar2 means variable character string. varchar2 has been introduced in higher verson  with higher limit. Means It can store more number of character as compared to Varchar

  Was this answer useful?  Yes

sireesha

  • Aug 3rd, 2006
 

Hi As u said the diff between varchar and varchar2 is wrong i think. varchar and varchar2 are same. upto 7i we have used varchar after 8i we are using varchar2. ur answer is the diff between char and varchar.

  Was this answer useful?  Yes

vidhya

  • Aug 29th, 2006
 

your reply is not correct.

both are of variable length

  Was this answer useful?  Yes

Gowri

  • Aug 30th, 2006
 

Both varchar and varchar2 are same which is of variable length characters but

in varchar maximum chars are 2000 and in later one is 4000 bytes.

barman

  • Sep 3rd, 2006
 

varchar,varchar2 both assigns memory,but varchar2 assigns double of what varchar assigns

Nagarajan

  • Sep 4th, 2006
 

In oracle both varchar and varchar2 are the same with 4096bytes max

  Was this answer useful?  Yes

Kiran

  • Sep 29th, 2006
 

Varchar and Varchar2 behave same in the latest versions of Oracle. Earlier Varchar could hold 2000 bytes and Varchar2 4000 bytes. In 10g, both are same. As said, Varchar is still kept for backward compatibility. Oracle has already warned users not to use Varchar but to use Varchar2. Oracle may depricate it or may use it for new datatype in future releases.

Santosh

  • Dec 13th, 2006
 

Dear,

The difference between Varchar2 and Varchar is :-

  1)Varchar2 Maxlength 4000    1)Varchar Maxlength 2000

Both are Variable length character data.

In coming Version of oracle u will not see Varchar

  Was this answer useful?  Yes

Guest

  • Jan 4th, 2007
 

VARCHAR in SQL Server corresponds to VARCHAR2 in Oracle. Again, their width is different (Oracle VARCHAR2 4000, SQL Server VARCHAR 8000).

  Was this answer useful?  Yes

poonama

  • Mar 9th, 2007
 

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.

  Was this answer useful?  Yes

Varchar & Varchar2 both are variable data type.

Difference:
First: Varchar is used in Oracle 8i version & varchar2 is used in oracle 9i
Second: Varchar's memory size is 2000 & varchar2's memory size is 4000.
Third:
Varchar2 is faster than Varchar.


  Was this answer useful?  Yes

ruchik999

  • Apr 25th, 2009
 

In case of varchar it store upto 2000 bytes and in case of varchar2 it stores 4000 bytes that is the basic difference between varchar and varchar2.

  Was this answer useful?  Yes

arunkumarb6

  • Jun 24th, 2011
 

 varchar and varchar2 both are same but the only difference is varchar can store 2000 bytes of characters and varchar2 can store 4000 bytes of characters.but oracle suggest varchar2 to use.varchar is for future use.

  Was this answer useful?  Yes

Kolta Sam

  • Jul 10th, 2011
 

VARCHAR2( ) -
Stores strings of variable length.
The length parameter specifies the maximum length of the strings
It stores up to 2000 bytes of characters.
It will occupy space for NULL values.
VARCHAR2( )
Stores strings of variable length.
The length parameter specifies the maximum length of the strings.
It stores up to 4000 bytes of characters.
It will not occupy space for NULL values.
The total length of strings is defined when strings are given

  Was this answer useful?  Yes

Avnish

  • Jul 19th, 2011
 

Code
  1.  

  2. CREATE TABLE avnish

  3. (Name varchar2(30),

  4. address varchar(30));

  5.  


Address field takes the 30 bytes space and that is fixed
, if you are inserting 'add1' in address field in address the it takes 4 bytes and rest 26 bytes are useless. 26 Bytes can't be used for another work.

if you are inserting 'name1' for Name field then it will occupy only 5 bytes,

  Was this answer useful?  Yes

Nishant Galav

  • Jul 30th, 2011
 

Actually varchar and vachar2 are the same thing but varchar2 is the advanced version of varchar. now a days even if we give the datatype varchar the computer understands it as varchar2 by default.

  Was this answer useful?  Yes

Nishant Galav

  • Jul 30th, 2011
 

varchar2 is used in 8i and above versions and varchar in lower versions than 8i.
varchar2 has max permitted length of about 4000 char
varchar has max permitted length of 2000 char

If we declare as following varchar(10) than all the 10 spaces are reserved and even if we use 5 spaces the rest 5 spaces will be wasted

BUT, in varchar2(10) if we use 5 spaces then the remaining 5 spaces will not be wasted it will be kept vacant and can be used.

  Was this answer useful?  Yes

GOVARDHANREDDY

  • Aug 12th, 2011
 

Char has fixed length where as varchar has variable length. For example if we take some employee name ramu and we can declare ename char(10) the output will be 10 where as using varchar declare ename varchar2(10) , it will give output as 4 only.

  Was this answer useful?  Yes

Hi All

Code
  1. SQL> CREATE TABLE temp (name varchar(10));

  2.  

  3. TABLE created.

  4.  

  5. SQL>

  6. SQL> INSERT INTO temp (name) VALUES('anand');

  7.  

  8. 1 row created.

  9.  

  10. SQL> commit;

  11.  

  12. Commit complete.

  13.  

  14. SQL> SELECT length(name) FROM temp;

  15.  

  16. LENGTH(NAME)

  17. ------------

  18.            5

  19.  

  20. SQL> CREATE TABLE temp2 (name char(10));

  21.  

  22. TABLE created.

  23.  

  24. SQL> INSERT INTO temp2 VALUES('anand');

  25.  

  26. 1 row created.

  27.  

  28. SQL>  SELECT length(name) FROM temp2;

  29.  

  30. LENGTH(NAME)

  31. ------------

  32.           10

  33.  

  Was this answer useful?  Yes

lakshmareddy

  • Sep 24th, 2011
 

varchar:-fixed length i.e,we cannot modify the word suppose lakshmareddy but in
varchar2:-variable length i.e., we can modify the word suppose pammilakshmareddy

  Was this answer useful?  Yes

Neha

  • Sep 25th, 2011
 

Currently VARCHAR behaves exactly the same as VARCHAR2. However, this type should not be used as it is reserved for future usage.

VARCHAR2 is used to store variable length character strings. The string value's length will be stored on disk with the value itself.

  Was this answer useful?  Yes

Arjun Bansal

  • Oct 1st, 2011
 

Varchar2 memory size is bigger then varchar memory size.

  Was this answer useful?  Yes


SQL> create table kalpu2(ename varchar2(10),address varchar(10));

Table created.

SQL> desc kalpu2;
Name Null? Type
----------------------------------------- -------- ----------------------------
ENAME VARCHAR2(10)
ADDRESS VARCHAR2(10)

SQL>
we give the varchar or varchar2 in oracle ,it automatically changed into varchar2.

the main difference between varchar2 and char is that the char data type is a fixed-length data type,any unused room is
blank padded with spaces.
for eg a column defined as char(10) and containing the five character length value kalpu in a row will have 5 blank characters padded at the end to make the total length 10 spaces.
if the column is stored in a varchar2(10) column instead, it stores 5 characters only.

  Was this answer useful?  Yes

venkat

  • Dec 4th, 2011
 

"varchar" allocates memory in dynamic fashion where as "varchar2" also allocates memory in dynamic fashion but it also supports garbage collection.
"varchar" is developed along with SQL where as "varchar2" is developed by Oracle.

  Was this answer useful?  Yes

shaik shamsheer

  • Dec 28th, 2011
 

In case of varchar it store upto 2000 bytes and in case of varchar2 it stores 4000 bytes
varchar is occupies space for the null value and varchar2 does not occupy space for null values.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions