当前位置:网站首页>sql server char nchar varchar和nvarchar的区别
sql server char nchar varchar和nvarchar的区别
2022-07-05 14:49:00 【蓝天⊙白云】
- char:固定长度,
存储ansi字符,不足的补英文半角空格。 - nchar:固定长度,
存储Unicode字符,不足的补英文半角空格。 - varchar(n):长度为 n 个字节的
可变长度且非 Unicode 的字符数据。n 必须是一个介于 1 和 8,000 之间的数值。存储大小为输入数据的字节的实际长度,而不是 n 个字节。 - nvarchar(n):包含 n 个字符的
可变长度 Unicode 字符数据。n 的值必须介于 1 与 4,000 之间。字节的存储大小是所输入字符个数的两倍。 - TEXT
text存储可变长度的非Unicode数据,最大长度为2^31-1(2,147,483,647)个字符。 - NCHAR、NVARCHAR、NTEXT
这三种从名字上看比前面三种多了个"N"。和char、varchar比较起来,nchar、nvarchar最多存储4000个字符,不论是英文还是汉字;而char、varchar最多能存储8000个英文,4000个汉字。可以看出使用nchar、nvarchar数据类型时不用担心输入的字符是英文还是汉字,较为方便,但在存储英文时数量上有些损失。
所以一般来说,如果含有中文字符,用nchar/nvarchar,如果纯英文和数字,用char/varchar。
边栏推荐
- [detailed explanation of Huawei machine test] happy weekend
- MySQL----函数
- Shanghai under layoffs
- 729. 我的日程安排表 I :「模拟」&「线段树(动态开点)」&「分块 + 位运算(分桶)」
- 想进阿里必须啃透的12道MySQL面试题
- How to paste the contents copied by the computer into mobaxterm? How to copy and paste
- GPS original coordinates to Baidu map coordinates (pure C code)
- [recruitment position] Software Engineer (full stack) - public safety direction
- IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
- GPS原始坐标转百度地图坐标(纯C代码)
猜你喜欢
随机推荐
【NVMe2.0b 14-9】NVMe SR-IOV
实现一个博客系统----使用模板引擎技术
Stm32+bh1750 photosensitive sensor obtains light intensity
leetcode:881. 救生艇
Cartoon: what are the attributes of a good programmer?
微帧科技荣获全球云计算大会“云鼎奖”!
Under the crisis of enterprise development, is digital transformation the future savior of enterprises
【招聘岗位】软件工程师(全栈)- 公共安全方向
超级哇塞的快排,你值得学会!
[detailed explanation of Huawei machine test] character statistics and rearrangement
Type declaration of all DOM elements in TS
Can I pass the PMP Exam in 20 days?
CODING DevSecOps 助力金融企业跑出数字加速度
Coding devsecops helps financial enterprises run out of digital acceleration
Jmeter性能测试:ServerAgent资源监控
Interview shock 62: what are the precautions for group by?
两个BI开发,3000多张报表?如何做的到?
[recruitment position] Software Engineer (full stack) - public safety direction
Isn't it right to put money into the external market? How can we ensure safety?
How to solve the problem of garbled code when installing dependency through NPM or yarn









