nvarchar(50)和nvarchar(MAX)之间的sql差异 [英] Sql difference between nvarchar(50) and nvarchar(MAX)

查看:194
本文介绍了nvarchar(50)和nvarchar(MAX)之间的sql差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道减少价值限制有什么好处吗?

为什么我们不直接在任何情况下直接给出(MAX)

会影响数据库还是某些东西?



我尝试了什么:



i用来做那个

给出最大值什么长度我需要,

只是给它nvarchar(MAX)

是错的?

I wondering is there any benefits of reducing the value limit?
Why we don't just give the (MAX) directly in any case
is that affects on the database or somthing?

What I have tried:

i used to do that
giving the max value what ever the length i need,
just give it nvarchar(MAX)
is that wrong?

推荐答案

请参阅此处: varchar(max) vs varchar(255) [ ^ ]


NVARCHAR(MAX)以不同方式存储在数据库中,因此场景非常清晰。



我认为你的问题更像是NVARCHAR(50)和NVARCHAR(500)有什么区别?假设500几乎总能保持你所需要的。看到名为last_name的字段是NVARCHAR(500)会让人感到困惑。没错,它不会对SQL内部产生任何影响,但为什么给人的印象是它可以保存那么多数据,以及如果你有一个最终会添加大量数据的错误呢?你不会立刻抓住它。



如果你想在NVARCHAR(25)和NVARCHAR(50)之间做出决定,那么显然可以选择50但是不要'你做的比你需要的更高。它只是让人困惑。
NVARCHAR(MAX) is stored on the database differently so that scenario is pretty clear.

I would think your question is more like "what is the difference between NVARCHAR(50) and NVARCHAR (500)?" assuming that 500 will nearly always hold what you need. It makes it confusing to see a field named last_name that is NVARCHAR (500). True, it won't make any difference internally to SQL but why give the impression that it can hold that much data and also what if you have a bug that ends up adding lots of data? You won't catch it right away.

If you are trying to decide between NVARCHAR (25) and NVARCHAR (50), then clearly go with 50 but don't do magnitudes higher than what you need. It just confuses people.


这篇关于nvarchar(50)和nvarchar(MAX)之间的sql差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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