Summary:"It is recommended to declare an alias using the AS keyword.",
Content:`在列或表别名(如"tbl AS alias")中, 明确使用AS关键字比隐含别名(如"tbl alias")更易懂。`,
Content:`In the alias of the column or table(such as "tbl AS alias"),it is easier to understand to use the keyword of AS clearly than implicit alias(such as "tbl alias")`,
},
"ALI.002":{
Summary:"An alias is not recommended for the column wildcard '*'.",
Content:`Eg:"SELECT tbl.* col1, col2",the SQL above set alias for wildcard of column,which may cause logical error.You may want to query col1,but the result will be renamed last column of tbl.`,
},
"ALI.003":{
Summary:"alias shouldn't be the same with column name or table name.",
Content:`表或列的别名与其真实名称相同, 这样的别名会使得查询更难去分辨。`,
Summary:"Alias shouldn't be the same with column name or table name.",
Content:`It will be hard to distinguish Alias of table or colomn when the alias is the same as it's real name.`,
},
"ALT.001":{
Summary:"modify the default character set will not modify the character set of each field in the table.",
Content:`很多初学者会将ALTER TABLE tbl_name [DEFAULT] CHARACTER SET 'UTF8'误认为会修改所有字段的字符集,但实际上它只会影响后续新增的字段不会改表已有字段的字符集。如果想修改整张表所有字段的字符集建议使用ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name;`,
Content:`Many beginner would think that "ALTER TABLE tbl_name [DEFAULT] CHARACTER SET 'UTF8' " will modify character set of all fields,but actually it can only influence new fileds but not that already exits.You may use "ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name;" if you want to modify character set of all fields.`,
},
"ALT.002":{
Summary:"recommend to merge multiple ALTER request if it's in the same table.",
Content:`Once the structure of table changed,the online service will be influenced.Please merge requests of ALTER to reduce the number of operations even though you can adjust it by online tools.`,
},
"ALT.003":{
Summary:"It's danger to delete column,please check if the business logic is still dependent before operation.",
Content:`If the business logic dosen't eliminated compeletly, you may can't write data or query the data of column begin deleted after column deleted,in which case you may lost data requested by users even by backup and recover.`,
},
"ALT.004":{
Summary:"It's danger to delete primary key and foreign key ,please check with DBA before operation.",
Content:`Primary key and foreign key are two important constraint in relational database,delete existing constraints may broken existing business logic,you may check the influence with DBA.`,
},
"ARG.001":{
Summary:"The use of the preceding wildcard query is not recommended.",
Content:`例如“%foo”,查询参数有一个前项通配符的情况无法使用已有索引。`,
Content:`Eg:"%foo",parameter of query has preceding wildcard will not use existing index.`,
},
"ARG.002":{
Summary:"LIKE query without wildcard.",
Content:`不包含通配符的LIKE查询可能存在逻辑错误,因为逻辑上它与等值查询相同。`,
Content:`LIKE query without wildcard may cause logic error,because it is the same as the equivalent query logically`,
},
"ARG.003":{
Summary:"Parameter comparisons contain implicit conversions, and indexes cannot be used.",
Content:"Implicit conversions has risk of unable to hit index,which may cause serious problem in case of high concurrency and large amount of data",
},
"ARG.004":{
Summary:"IN (NULL)/NOT IN (NULL) , always false.",
Content:"正确的作法是col IN ('val1', 'val2', 'val3') OR col IS NULL",
Content:`You may use "col IN ('val1', 'val2', 'val3') OR col IS NULL"`,
},
"ARG.005":{
Summary:"Use IN with caution,too many elements will lead to a full table scan.",
Content:` 如:select id from t where num in(1,2,3)对于连续的数值,能用BETWEEN就不要用IN了:select id from t where num between 1 and 3。而当IN值过多时MySQL也可能会进入全表扫描导致性能急剧下降。`,
Content:` Eg:"select id from t where num in(1,2,3)" as mentioned above,use BETWEEN instead of IN as you can for continuous values,such as "select id from t where num between 1 and 3".because MYSQL may scan the whole table when there are too many IN values,which may make sharp decline in performance`,
},
"ARG.006":{
Summary:"Try to avoid judge NULL values in WHERE clause.",
Content:`使用IS NULL或IS NOT NULL将可能导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null;可以在num上设置默认值0,确保表中num列没有null值,然后这样查询: select id from t where num=0;`,
Content:`The engine may scan the whole table instead of use index when you use "IS NULL" or "IS NOT NULL",such as "select id from t where num is null".You can set num as 0 by default to make sure there is no null value in the colnumn of num,then you can use "select id from t where num=0"`,
Content:`Performance are the biggest problem of using pattern matching operators,another problem that it may return unexpected results will be caused by using LIKE or regular expression to pattern matching,so a better program is to use special search engine technology instead of SQL such as "Apache Lucene".Besides,another optional program is to save results to reduce overhead from Repeated search.If you really want to use SQL,please consider to use third party extension like FULLTEXT index in MySQL.Acctually,SQL is not the one way to solve all problem.`,
},
"ARG.008":{
Summary:"Try to use IN when you execute an OR query in an index column.",
Content:`The predicate of IN-list can be used by index to search,and optimizer can sort to IN-list to match the sorted sequence of index,which can make more effective search.Please pay attention to that IN-list must include constant only,or keep value of constant during query block execution such as external reference.`,
},
"ARG.009":{
Summary:"The string in the quotation mark contains white space at the beginning or the ending.",
Content:`The space before or after the column of VARCHAR may cause logic problem,for example, it will be considered the same that 'a' and 'a ' in MySQL 5.5`,
},
"ARG.010":{
Summary:"Don't use hint,such as : sql_no_cache, force index, ignore key, straight join.",
Content:`hint is used to force SQL executes according to a executing plan,but we can't promise which we predict at the beginning correct as data changed`,
},
"ARG.011":{
Summary:"Don't use negative query,such as:NOT IN/NOT LIKE",
Content:`请尽量不要使用负向查询,这将导致全表扫描,对查询性能影响较大。`,
Content:`Don't use negative query,which may cause whole table scanned and affect query performance`,
},
"CLA.001":{
Summary:"No where condition for select statement",