MySQL 表中 varchar 长度的重要性 [英] Importance of varchar length in MySQL table

查看:39
本文介绍了MySQL 表中 varchar 长度的重要性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 MySQL 表,其中的行是动态插入的.因为我不能确定字符串的长度并且不希望它们被切断,所以我使它们 varchar(200) 通常比我需要的大得多.为 varchar 字段提供比所需更长的长度是否会对性能造成很大影响?

I have a MySQL table where rows are inserted dynamically. Because I can not be certain of the length of strings and do not want them cut off, I make them varchar(200) which is generally much bigger than I need. Is there a big performance hit in giving a varchar field much more length than necessary?

推荐答案

不,如果您存储在该列中的值始终(例如)少于 50 个字符,则将该列声明为 varchar(50)varchar(200) 具有相同的性能.

No, in the sense that if the values you're storing in that column are always (say) less than 50 characters, declaring the column as varchar(50) or varchar(200) has the same performance.

这篇关于MySQL 表中 varchar 长度的重要性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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