Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL MySQL
Please help me understand: What is the difference between varchar, nvarchar, char & nchar in mysql?
Posted 2-Jul-13 21:43pm
Edited 2-Jul-13 23:48pm
Johnny J.115.6K
v3
Comments
Zoltán Zörgő at 3-Jul-13 2:45am
   
Tag this as SQL not C#!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
jaideepsinh at 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)

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 3 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100