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)這種帶子查詢的更新

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