开发者

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 valu开发者_开发技巧es 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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜