特定字段(列)中数据库中的数据量 [英] Amount of data in database for certain field (column)
本文介绍了特定字段(列)中数据库中的数据量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以获取有关mysql或任何其他数据库中一个字段(列)中数据量的信息?
Is it possible to get information about amount of data in one field (column) in mysql or any other db?
推荐答案
如果它是 varchar
类型,它将告诉您该列使用的字节数:
If it's a varchar
type, this will tell you the number of bytes used by the column:
select sum(length(column_name)) + count(*) as total_bytes from table_name;
对于 varchar
,每增加一个字节行(即添加 count(*)
)。
For varchar
, you add 1 byte per row (ie add count(*)
).
如果它是 char
,只需将count(*)乘以列宽即可。
If it's char
, simply multiply count(*) by the column width.
这篇关于特定字段(列)中数据库中的数据量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文