Home » SQL & PL/SQL » SQL & PL/SQL » diff b/w varchar
diff b/w varchar [message #10547] Thu, 29 January 2004 07:44 Go to next message
ashokmote
Messages: 56
Registered: December 2003
Member
wat is the difference b/w char and varchar.

and also difference b/w varchar and varchar2.
Re: diff b/w varchar [message #10553 is a reply to message #10547] Fri, 30 January 2004 00:23 Go to previous messageGo to next message
resy
Messages: 86
Registered: December 2003
Member
CHAR(n) Fixed length character data of length n bytes. Maximum size is 2000 bytes.
Default and minimum n is 1 byte.

VARCHAR2(n) Variable-length character string having maximum length of n bytes.
Maximum size is 4000, and minimum is 1. No trailing blank spaces are
added and hence the recommended data type for most character columns.

CHAR, NCHAR, VARCHAR2 and NVARCHAR2
Character data types store character data in the database character or national character set.

CHAR[[(n)]]

Fixed-length character data of length n bytes. The maximum length is 2000 bytes, the default value is 1.

NCHAR[[(n)]]

Fixed-length character data of length n characters or bytes, depending on the national character set. The maximum length is determined by the number of bytes required to store each character, with an upper limit of 2000 bytes. The default value is 1.

VARCHAR2(n)

Variable-length character data with length of n characters. The maximum length is 4000 bytes. You must specify the maximum length for VARCHAR2 columns.

NVARCHAR2(n)

Variable-length character data having maximum length n characters or bytes, depending on the national character set. The maximum length is determined by the number of bytes required to store each character, with an upper limit of 4000 bytes. You must specify the maximum length for NVARCHAR2 columns.
Re: diff b/w varchar [message #10561 is a reply to message #10547] Fri, 30 January 2004 08:15 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
"VARCHAR is currently synonymous with the VARCHAR2 datatype. Oracle recommends that you use VARCHAR2 rather than VARCHAR. In the future, VARCHAR might be defined as a separate datatype used for variable-length character strings compared with different comparison semantics."
Re: diff b/w varchar [message #10563 is a reply to message #10547] Fri, 30 January 2004 11:19 Go to previous message
Satish Shrikhande
Messages: 167
Registered: October 2001
Senior Member
Char datatype does blank space padding and varchar , varchar2 doesn't .
If you define column1 char(5) and entered only 2 characters , but it will stores as 5 charatcters with 3 black spaces , that's we use char data type only when we are sure we are going to enter that many characters .

Thanks!
Satish Shrikhande
http://www.freewebs.com/oracledba/oracle.htm
Previous Topic: Session history
Next Topic: future with oracle
Goto Forum:
  


Current Time: Fri Apr 26 13:32:46 CDT 2024