MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Varchar

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
venkat
Guest






PostPosted: Thu Oct 21, 2004 5:52 am    Post subject: Varchar Reply with quote

1)what is the difference between char & Varchar.
2)How is the data stored in Varchar.explain with examples how is the data stored in char & varchar.
Back to top
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Oct 21, 2004 6:03 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group