确定mysql中的一列中允许的最大长度 [英] Determine max length allowed in a column in mysql
本文介绍了确定mysql中的一列中允许的最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表的结构类似于:
registrant_id varchar(16)
registrant_name varchar(128)
我想运行一个查询,该查询显示所有与最大PERMISSIBLE长度相匹配的条目,即我目前为上述操作所做的事情:
I want to run a query that displays all those entries which match the maximum PERMISSIBLE length, ie what I do currently do for the above:
SELECT *
FROM `tm_registrant`
WHERE length( `registrant_name` ) = 128
但是,我不想对128进行硬编码,因为我有很多列,并且想运行一个查询来查看所有至少有一个完全填满"的列的条目.
However, I dont want to hardcode 128 as I have many columns and want to run one query to see all the entries which have atleast one completely 'filled up' column.
推荐答案
SELECT CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'your_table_name'
AND table_schema = 'your_db_name'
AND column_name = 'your_column_name'
LIMIT 0 , 1
这篇关于确定mysql中的一列中允许的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文