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

Recommended Answers

All 5 Replies

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...

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!

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:

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?

No. What you said is correct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.