kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Thu Oct 21, 2004 6:03 am Post subject: |
|
|
venkat,
If your questions are for interview purposes please state it. It gives an idea on how to answer such basic questions.
The real difference between CHAR and VARCHAR is the VARCHAR is variable, hence the VAR. Let us say you created a table like this
Code: |
CREATE TABLE contacts (
contact_id INT NOT NULL ,
first_name CHAR (30) NULL ,
last_name CHAR (50) NULL ,
email VARCHAR (75) NULL
);
|
This means that when someone new is entered in the database the "first_name" and "last_name" columns will have a fixed size, 30 and 50 respectively, no matter how little information you put in them. So, if you entered the name "John" in the "first_name" column, it would take up a 30 character block of storage instead of only the 4 characters it really needs. With VARCHAR it would only take up as much space is needed for storage. VARCHAR does come with a minimum storage requirement.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|