We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如果你接手了一个垃圾项目,MySQL 表甚至有几百个,字段的类型很多都是varchar(100),偶尔发现存入的数据被截断,排查了半天发现是长度不够,那这个脚本可能能帮到你。
varchar(100)
没错,我就是被这种项目折磨过,写了一个脚本用来检查哪些表的字段的数据已经溢出,代码简单,我放在了 gist :https://gist.github.com/woodongwong/4bcf9a792c15e0ffbd5a4e6271b0a269
用法:
pip3 install pymysql python3 check_mysql_data_overflow.py -u myuser -H myserver.example.com -P 3306 -d mydatabase -t mytable -p
如果不指定-t则检查数据库所有的表。
-t
输出:
The table news field content has overflowed its capacity, with a total of 2 data entries.
检查的原理很简单,统计字段的每行数据的长度,如果等于当前字段类型的长度,就判断为内容已经溢出。 检查的类型有 varbinary varchar blob text mediumblob mediumtext longblob longtext。
varbinary
varchar
blob
text
mediumblob
mediumtext
longblob
longtext
注意:不建议在生产运行;如果数据量很大,不要运行;此脚本会扫描全表
The text was updated successfully, but these errors were encountered:
No branches or pull requests
如果你接手了一个垃圾项目,MySQL 表甚至有几百个,字段的类型很多都是
varchar(100)
,偶尔发现存入的数据被截断,排查了半天发现是长度不够,那这个脚本可能能帮到你。没错,我就是被这种项目折磨过,写了一个脚本用来检查哪些表的字段的数据已经溢出,代码简单,我放在了 gist :https://gist.github.com/woodongwong/4bcf9a792c15e0ffbd5a4e6271b0a269
用法:
如果不指定
-t
则检查数据库所有的表。输出:
检查的原理很简单,统计字段的每行数据的长度,如果等于当前字段类型的长度,就判断为内容已经溢出。
检查的类型有
varbinary
varchar
blob
text
mediumblob
mediumtext
longblob
longtext
。注意:不建议在生产运行;如果数据量很大,不要运行;此脚本会扫描全表
The text was updated successfully, but these errors were encountered: