简介

procedure analyse()函数是MySQL内置的对MySQL字段值进行统计分析后给出建议的字段类型。

语法

procesure analyse(max_elements,max_memory)

max_elements

指定每列非重复值的最大值,当超过这个值的时候,MySQL不会推荐enum类型。

max_memory

analyse()为每列找出所有非重复值所采用的最大内存大小。

实战演练

# 对t1表所有的列进行分析
wing@3306>show create table t1;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                      |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1  | CREATE TABLE `t1` (
 `id` int(11) DEFAULT NULL,
 `name` varchar(16) DEFAULT NULL,
 `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
wing@3306>select * from t1 procedure analyse(4);
+---------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+-------------+--------------------------------+
| Field_name  | Min_value | Max_value | Min_length | Max_length | Empties_or_zeros | Nulls | Avg_value_or_avg_length | Std     | Optimal_fieldtype       |
+---------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+-------------+--------------------------------+
| wing.t1.id  | 1     | 200000  |     1 |     6 |        0 |   0 | 100000.5000       | 116099.2790 | MEDIUMINT(6) UNSIGNED NOT NULL |
| wing.t1.name | 000jxc6V | zzznmkcX |     8 |     8 |        0 |   0 | 8.0000         | NULL    | CHAR(8) NOT NULL        |
| wing.t1.score | 1     | 100    |     1 |     3 |        0 |   0 | 50.4889         | 28.8768   | TINYINT(3) UNSIGNED NOT NULL  |
+---------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+-------------+--------------------------------+
3 rows in set (0.14 sec)

总结

以上就是关于MySQL中procedure analyse()函数的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com