为什么VARCHAR需要长度规范? [英] Why does VARCHAR need length specification?

查看:668
本文介绍了为什么VARCHAR需要长度规范?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们总是需要指定 VARCHAR(length)而不是 VARCHAR ?它是动态的。

Why do we always need to specify VARCHAR(length) instead of just VARCHAR? It is dynamic anyway.

UPD:我非常困惑的事实,它是强制性的(例如在MySQL)。

UPD: I'm puzzled specifically by the fact that it is mandatory (e.g. in MySQL).

推荐答案

VARCHAR的length不是内容的长度,而是内容的最大长度。

The "length" of the VARCHAR is not the length of the contents, it is the maximum length of the contents.

VARCHAR的最大长度不是动态的,它是固定的,因此必须指定。

The max length of a VARCHAR is not dynamic, it is fixed and therefore has to be specified.

如果不想定义最大长度然后使用VARCHAR(MAX)。

If you don't want to define a maximum size for it then use VARCHAR(MAX).

这篇关于为什么VARCHAR需要长度规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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