Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help me understand: What is the difference between varchar, nvarchar, char & nchar in mysql?
Posted
Updated 2-Jul-13 22:48pm
v3
Comments
Zoltán Zörgő 3-Jul-13 2:45am    
Tag this as SQL not C#!

Check here: http://bit.ly/14Pizaz[^]

But:
- "n" stands for national - it means, that the RDBMS is storing values as multibyte string using one or another encoding[^], as UTF-8 and so on
- the difference between char and varchar was originally the padding: "abc" in a char(5) filed would be "abc " (note the spaces), while in varchar(5) would be just "abc". As systems evolved, the internal storage handling of these two approaches became different. But that depends on the RDBSM also.
In case of Microsoft SQL Server, this will give you future clarification: http://msdn.microsoft.com/en-us/library/ms176089.aspx[^]
In case of MySQL, you should read this too: http://dev.mysql.com/doc/refman/5.0/en/char.html[^]
 
Share this answer
 
v2
SQL
char : - char stores fixed length of character. if you declare char(50) then it allocates memory for 50 characters. if you store 10 character word then it store it in 10 characters memory location and other 40 character's memory location will be wasted.

varchar : - varchar means variable characters. it allocates memory as per data stored into this. If you specify varchar(50) at the time of declaration then it allocates 0 memory location at the starting if you specify, it can be null. When you store 10 characters word it will allocate memory for 10 characters and store into that. So there will be no memory loss. It stores only non-unicode characters.

nvarchar : - nvarchar means unicode variable characters. it allocates memory as same as varchar. But It stores unicode characters.
 
Share this answer
 
Comments
jaideepsinh 3-Jul-13 3:14am    
Here briefly explain:
http://sqlhints.com/2011/12/23/difference-between-varchar-and-nvarchar/[^]
If solve accept as answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900