Home » SQL & PL/SQL » SQL & PL/SQL » CHAR DATATYPE: FIXED?
CHAR DATATYPE: FIXED? [message #284] Sun, 03 February 2002 21:13 Go to next message
JOHN
Messages: 182
Registered: April 1998
Senior Member
Can you tell me the diffrence between 'char'and 'varchar2'?
Re: CHAR DATATYPE: FIXED? [message #297 is a reply to message #284] Mon, 04 February 2002 03:58 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
major differences:

1) char column max length 2000
varchar2 max length 4000
(in oracle 8 and above)

2) if you define column as char datatype, oracle pads spaces and insert value

ex:
if you define ename as char(50)

insert into emp(ename) values('xyz');

oracle stores values xyz+47spaces
means length of that column always 50.

oracle inserts actual value when u define column as varchar2

above value will be stored as 'xyz'

varchar2 datatype saves lot of space.
Re: CHAR DATATYPE: FIXED? [message #334 is a reply to message #284] Tue, 05 February 2002 22:43 Go to previous message
Diwakar Bhandari
Messages: 1
Registered: February 2002
Junior Member
Then a question arises why there is a need to go for char datatype when we already have varchar2 which beneficial in saving memory ... The reason as I belief is that char is to be used for those column where the database designer is sure of the length of the values to be entered ..say like sex which can only be 'M' or 'F' . Varchar2 though saves memory but it can be a performance overload as it comes into play at the runtime (determining the length of string to be stored ) and hence if we are talking of performnace , then it can be an overhead .Hence char is still relevant inspite of being pretty harsh on memory ..!!!!
Previous Topic: SQL intro-SQL tutorial just for warmers
Next Topic: Help - Sql statement
Goto Forum:
  


Current Time: Fri Apr 26 18:31:17 CDT 2024