当前位置:网站首页>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。
边栏推荐
- MySQL之CRUD
- [summary of leetcode weekly competition] the 81st fortnight competition of leetcode (6.25)
- Detailed explanation of usememo, memo, useref and other relevant hooks
- 【NVMe2.0b 14-9】NVMe SR-IOV
- be careful! Software supply chain security challenges continue to escalate
- 有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
- JS bright blind your eyes date selector
- FR练习题目---简单题
- MySQL----函数
- 【C 题集】of Ⅷ
猜你喜欢
随机推荐
【招聘岗位】软件工程师(全栈)- 公共安全方向
CODING DevSecOps 助力金融企业跑出数字加速度
Pointer operation - C language
爱可可AI前沿推介(7.5)
12 MySQL interview questions that you must chew through to enter Alibaba
FR练习题目---综合题
【招聘岗位】基础设施软件开发人员
超越PaLM!北大硕士提出DiVeRSe,全面刷新NLP推理排行榜
JS bright blind your eyes date selector
GPS原始坐标转百度地图坐标(纯C代码)
【NVMe2.0b 14-9】NVMe SR-IOV
GPS original coordinates to Baidu map coordinates (pure C code)
Coding devsecops helps financial enterprises run out of digital acceleration
两个BI开发,3000多张报表?如何做的到?
Structure - C language
Install and configure Jenkins
Cartoon: what are the attributes of a good programmer?
Photoshop plug-in action related concepts actionlist actiondescriptor actionlist action execution load call delete PS plug-in development
How to solve the problem of garbled code when installing dependency through NPM or yarn
Two Bi development, more than 3000 reports? How to do it?









