简体   繁体   English

有没有认真的MySQL命名样式指南?

[英]Is there any serious MySQL naming styleguide?

As you can saw in Table name show a syntax error in MySQL question you can define some particular tablename ( attn-cse-a[3-1][mpms][10-8-2013] ). 正如您在表名显示MySQL问题中的语法错误中所看到的那样,您可以定义一些特定的表名( attn-cse-a[3-1][mpms][10-8-2013] )。

A comment suggest to use only alphanumeric chars as good tablename, but this is really a wise choice? 有评论建议仅使用字母数字字符作为良好的表名,但这真的是一个明智的选择吗? What about of "-" and "_"? 那“-”和“ _”呢?

Is there any serious styleguide to MySQL naming of tables, columns, index, etc.? 对于表,列,索引等的MySQL命名,是否有任何严肃的风格指南?

I say MySQL because of big differences between DB syntax rules of SQL servers, but of course can be a generic SQL naming styleguide! 我说MySQL是由于SQL服务器的数据库语法规则之间的巨大差异,但是当然可以作为通用SQL命名样式指南!

The MySQL Reference Manual has a pretty good description of what is allowed: MySQL参考手册对允许的内容进行了很好的描述:

http://dev.mysql.com/doc/refman/5.5/en/identifiers.html http://dev.mysql.com/doc/refman/5.5/en/identifiers.html

Personally I use a subset of the allowable characters for unquoted identifiers, which the manual describes as follows: 我个人使用允许字符的子集作为未加引号的标识符,该手册描述如下:

  • Permitted characters in unquoted identifiers: 未加引号的标识符中允许的字符:
    • ASCII: [0-9,az,AZ$_] (basic Latin letters, digits 0-9, dollar, underscore) ASCII:[0-9,az,AZ $ _](基本拉丁字母,数字0-9,美元,下划线)
    • Extended: U+0080 .. U+FFFF 扩展:U + 0080 .. U + FFFF

Restricting that list further, I would not use any of the following in table/column names or other identifiers: 进一步限制该列表,我不会在表/列名称或其他标识符中使用以下任何内容:

So basically that leaves you with alphanumeric characters and underscores, but avoid reserved words. 因此基本上,您可以使用字母数字字符和下划线,但要避免使用保留字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM