0

Can someone clarify me the difference between CHAR and VCHAR and which one is best to be default type in my all SQL queries?
Is it VCHAR or CHAR? :D

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by nav33n
0

Can someone clarify me the difference between CHAR and VCHAR and which one is best to be default type in my all SQL queries?
Is it VCHAR or CHAR? :D

Varchar is the best option what i know...because char is fixed length...but varchar is automatically change size based on the input....If u use char, than memory wastage is more...

0

http://www.mssqlcity.com/FAQ/General/char_vs_varchar.htm

Summary: If you specify column's datatype as char(20) and you enter a value, say, "test", mysql still uses 20 bytes.. But if the column's datatype is varchar, and you enter "test", it uses only 4 bytes.. The best place to use char is when you are 100% sure that you save only a fixed length value, for example, a boolean "Y" or "N".

P.S. I am not too sure about the bytes used. This is just to give you a gist!

0

Varchar is the best option what i know...because char is fixed length...but varchar is automatically change size based on the input....If u use char, than memory wastage is more...

Ah! You beat me by 4 mins :twisted:

0

Ah! You beat me by 4 mins :twisted:

Hi Naveen,

Yah U r correct...ok is there any wrong with my answer..plz tell me...if any?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.