Click here to Skip to main content
13,056,238 members (110,585 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Please help me understand: What is the difference between varchar, nvarchar, char & nchar in mysql?
Posted 2-Jul-13 20:43pm
Updated 2-Jul-13 22:48pm
Johnny J.167K
Zoltán Zörgő 3-Jul-13 2:45am
Tag this as SQL not C#!
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Check here:[^]

- "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:[^]
In case of MySQL, you should read this too:[^]
Rate this: bad
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.
jaideepsinh 3-Jul-13 3:14am
Here briefly explain:[^]
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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170728.5 | Last Updated 3 Jul 2013
Copyright © CodeProject, 1999-2017
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