当前位置:网站首页>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。
边栏推荐
- Reconnaissance des caractères easycr
- anaconda使用中科大源
- Crud of MySQL
- Run faster with go: use golang to serve machine learning
- FR练习题目---综合题
- Thymeleaf uses background custom tool classes to process text
- Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
- How to choose the appropriate certificate brand when applying for code signing certificate?
- [recruitment position] infrastructure software developer
- 729. My schedule I: "simulation" & "line segment tree (dynamic open point) &" block + bit operation (bucket Division) "
猜你喜欢

Photoshop plug-in action related concepts actionlist actiondescriptor actionlist action execution load call delete PS plug-in development

MySQL之CRUD

P1451 求细胞数量/1329:【例8.2】细胞

How to paste the contents copied by the computer into mobaxterm? How to copy and paste

Dark horse programmer - software testing -10 stage 2-linux and database -44-57 why learn database, description of database classification relational database, description of Navicat operation data, de

Creation and use of thymeleaf template

Interview shock 62: what are the precautions for group by?

计算中间件 Apache Linkis参数解读

百亿按摩仪蓝海,难出巨头

CODING DevSecOps 助力金融企业跑出数字加速度
随机推荐
选择排序和冒泡排序
亿咖通科技通过ISO27001与ISO21434安全管理体系认证
Un week - end heureux
开挖财上的证券账户可以吗?安全吗?
可转债打新在哪里操作开户是更安全可靠的呢
【NVMe2.0b 14-9】NVMe SR-IOV
PostgreSQL 13 installation
js亮瞎你眼的日期选择器
Isn't it right to put money into the external market? How can we ensure safety?
729. My schedule I: "simulation" & "line segment tree (dynamic open point) &" block + bit operation (bucket Division) "
Ecotone technology has passed ISO27001 and iso21434 safety management system certification
P6183 [USACO10MAR] The Rock Game S
有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
How to open an account of qiniu securities? Is it safe to open an account?
超级哇塞的快排,你值得学会!
MySQL之CRUD
实现一个博客系统----使用模板引擎技术
Easyocr character recognition
【招聘岗位】软件工程师(全栈)- 公共安全方向
百亿按摩仪蓝海,难出巨头