inception审核规则详解

inception审核规则详解

  规则简介:

配制文件 inc.cnf

 

            一  INSERT

             1 在插入中,必须指定插入的列名,即使全部插入,也需要指定每个列名。(insert into a(a,b,c) values(123,213,13))  inception_check_insert_field=>默认开启

             2 标记 not null的列,如果插入的值是null,报错  inception_enable_nullable=》默认开启

            二 UPDATE,DELETE

             1 必须有where条件   inception_check_dml_where=>默认开启

             2 delete语句不能有limit条数  inception_check_dml_limit=》默认开启

             3 不能有order by语句  inception_check_dml_orderby=>默认开启

             4 影响行数大于10000条,则报警 inception_max_update_rows=》默认开启 可以设置 1-》max(默认值10000)

             5 其他就是对于where条件的处理,就不一一说明了

          三  Create

               此项规则最多,这块也是可以自由定制的最多模块,我只对于自己线上的功能进行定制开发

                1 列的类型不能使用集合、枚举、位图类型。 inception_enable_enum_set_bit=》默认关闭(如果线上不需要这些类型,强烈建议开启这个参数)

                2 列必须要有注释  inception_check_column_comment=>默认开启(建议开启)

                3 表必须要有注释  inception_check_table_comment=》默认开启(建议开启)

                4 每个列都使用not null   inception_enable_nullable=》默认开启(建议开启)

                5 建表指定的存储引擎不为Innodb,不报错   inception_enable_not_innodb=》默认关闭(建议关闭,另外,以后都是innodb的天下了,放弃myisam吧)

                6 表必须要有主键  inception_check_primary_key=>默认开启(建议开启,主键对于表示非常重要的)

                7 支持外键 inception_enable_foreign_key=>默认开启(根据业务需求来确定是否开启)

                8 支持分区表 inception_enable_partition_table=》默认关闭(根据业务需求来确定是否开启)

                9 创建或者新增列时如果列为NULL,进行警告 inception_enable_nullable=》默认开启(建议开启)

                10 建表时,必须为timestamp类型指定默认值 inception_check_timestamp_default=》默认开启(建议开启)

                11 建库建表所支持的字符集 inception_support_charset=(utf8/utf8mb4)

                12 指定列的字符集  inception_enable_column_charset =》默认关闭(不建议开启)

                13  建表时的自增类型必须为int or bigint  inception_check_autoincrement_datatype=》默认开启(建议开启,因为这类自增的一般都是主键类型)

                14  建表时的自增类型初始值指定必须为1 inception_check_autoincrement_init_value=》默认开启(建议开启)

                15  建表时的自增类型为无符号型 inception_enable_autoincrement_unsigned=》默认开启(建议开启)

                16  建表时的自增类型命名为ID  inception_check_autoincrement_name=>默认开启(不建议开启)

                17  添加索引时,索引名必须以idx_命名 ,唯一索引的前缀是uniq_  inception_check_index_prefix=>默认开启(建议开启,规范命名)

                18  一个表中,索引的条数不能大于某个值  inception_max_keys=>默认16(可以设置1-1024)

                19 一个索引中,列的个数不能大于某个值   inception_max_key_parts=》默认5 (可以设置1-64)

                20 当数据类型char的长度大于某个值,转化为varchar类型  inception_max_char_length=》默认16(可以设置1-MAX,看场景需求选择最大值)

                21 合并多个语句,针对同一张表  inception_merge_alter_table=》默认开启(没测试过,不太明白)

                22  列是否支持 blob的操作   inception_enable_blob_type=》默认开启(看业务场景)

                23  检测关于列的操作是否有默认值(修改 添加)  inception_check_column_default_value => 默认开启(建议开启)

   五  DDL :

         关于DDL的操作 强烈建议不要走inception, 由DBA自己判断执行。原因很简单,一旦涉及到大表的DDL操作,哪怕是调用PT工具,在业务高峰期依然会执行有问题(本人曾经遇到过因为业务导致的PT工具无法创建触发器问题)

          inception_ddl_support => 默认值为关闭

   六 如何修改变量:

        1 登陆inception 服务 

         mysql -P  服务端口  -h  host    

       2  执行命令  

          inception get variables;

       3  进行设置

          inception set variable_name=value;

   七  测试和beta环境中使用的规则

         

     inception_check_autoincrement_datatype 检测自增长类型
     inception_check_autoincrement_init_value 检测自增长初始值
     inception_check_autoincrement_name 检测自增长名字
     inception_check_column_comment 检测每列的comment|
     inception_check_dml_limit 检测update,delete 不应该有 limit
     inception_check_dml_orderby 检测update,delete 不应该有 order by
     inception_check_dml_where 检测update,delete 必须要有 where
     inception_check_identifier 检测各种命名是否符合mysql规则(字母下划线数字)
     inception_check_index_prefix 检测index的命名 普通索引idx_ 唯一索引uniq_
     inception_check_insert_field 检测insert 语句必须要有列名
     inception_check_primary_key 检测表必须要有主键
     inception_check_table_comment 检测表必须要有commet
     inception_check_timestamp_default 检测列类型timestamp必须要有默认值
     inception_ddl_support 支持DDL操作
     inception_enable_autoincrement_unsigned 检测自增长必须要为无符号型
     inception_enable_blob_type 支持blob类型
     inception_enable_nullable 检测列类型是否为NULL
     inception_enable_orderby_rand 不支持order by rand
     inception_enable_partition_table 不支持分区表 |
     inception_max_char_length char长度超过16就会转为varchar
     inception_max_key_parts 一个索引不能超过5列
     inception_max_keys 一张表最多不能超过16个
     inception_merge_alter_table DML对于同一张表的合并

 

 一些补充

     1 inception不支持select

     2 inception不支持update(select)这种带子查询的更新

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章