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

查看:88
本文介绍了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天全站免登陆