简体   繁体   中英

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] ).

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.?

I say MySQL because of big differences between DB syntax rules of SQL servers, but of course can be a generic SQL naming styleguide!

The MySQL Reference Manual has a pretty good description of what is allowed:

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)
    • Extended: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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