char类型之间的区别 [英] Difference between char types

查看:82
本文介绍了char类型之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我理解:mysql中varchar,nvarchar,char和nchar有什么区别?

Please help me understand: What is the difference between varchar, nvarchar, char & nchar in mysql?

推荐答案

点击这里:http://bit.ly/14Pizaz [ ^ ]



但是:

- n代表国家 - 这意味着,RDBMS将值存储为多字节字符串使用一个或多个编码 [ ^ ],如UTF-8等等

- char和varchar之间的区别最初是填充: abc char(5)提交的文件中 abc (注意空格),而在varchar(5)中只是 abc 。随着系统的发展,这两种方法的内部存储处理变得不同。但这也取决于RDBSM。

如果是Microsoft SQL Server,这将为您提供未来的说明: http: //msdn.microsoft.com/en-us/library/ms176089.aspx [ ^ ]

如果是MySQL,你也应该阅读:http://dev.mysql.com/doc/refman/5.0/en/char.html [ ^ ]
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[^]


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.


参考这个......:)



http://www.dotnetfunda.com/forums/thread4655-difference-between -char-varchar-nvarchar.aspx [ ^ ]
Refer this...: )

http://www.dotnetfunda.com/forums/thread4655-difference-between-char-varchar-nvarchar.aspx[^]


这篇关于char类型之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆