简体   繁体   English

在数据库中查找接近极限的工具?

[英]Tool to find columns in a database approaching limit?

Can anyone point me to a tool, script, method, query, etc. that will help me find all columns in a database that have values approaching the size limit of the column? 谁能指出我的工具,脚本,方法,查询等信息,这些信息将帮助我在数据库中找到所有值都接近该列大小限制的列?

For example, if I happen to have a column that is a smallint(8) - the maximum value possible to store in that column is 32767. If any of the rows in that table have a value that is say... more than 90% of that limit for that column, I would like to know. 例如,如果我碰巧有一个smallint(8)列-可能存储在该列中的最大值是32767。如果该表中的任何行的值都表示...大于90我想知道该列的限制百分比。

Thanks. 谢谢。

For integers that's easy: 对于整数,这很简单:

SELECT * FROM a WHERE a.anumber > (32767 * 0.9)

For text you can use the length function. 对于文本,您可以使用长度功能。

SELECT * FROM a WHERE LENGTH(a.stringfield) > 20;

Note that using a function kills any chance of using an index on that field. 请注意,使用函数会杀死在该字段上使用索引的任何机会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM