What rules apply to naming a mysql column?

mysql column name reserved word
mysql table name convention
mysql table name length
mysql max column name length
mysql naming conventions best practices
mysql database name rules
mysql column name start with underscore
mysql reserved words

In a MySQL table, naming a column, can I use

  • spaces
  • uppercase letters
  • UTF8 characters

What other rules shall I follow?

( MySQL5 )


Yes, Yes, and Yes.

I like underscores between field names and no uppercase, but I don't want to start a flame war.

Another good reason to not use special characters in column names is you, or others are eventually going to have to type that over and over in your application. I'd stick to the standard english alphabet.

Good column names:

account_id
user_id
first_name

Bad column name:

Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝
uraniumType☢☢☢☢

What rules apply to naming a mysql column?, , and indexes can be up to 64 characters long. MySQL Naming Rules. Almost every SQL statement refers in some way to a database or its constituent elements. This section describes the syntax rules for referring to databases, tables, columns, indexes, and aliases. Names are subject to case sensitivity considerations, which are described as well. Referring to Elements of Databases


MySQL Naming Rules, Yes, Yes, and Yes. I like underscores between field names and no uppercase, but I don't want to start a flame war. Another good reason to not  MySQL Naming Rules Almost every SQL statement refers in some way to a database or its constituent elements. This section describes the syntax rules for referring to databases, tables, columns, indexes, and aliases.


From mysql 8.0 reference manual at https://dev.mysql.com/doc/refman/8.0/en/identifiers.html:

"Identifiers are converted to Unicode internally. They may contain these characters:

Permitted characters in unquoted identifiers:

ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)

Extended: U+0080 .. U+FFFF

Permitted characters in quoted identifiers include the full Unicode Basic Multilingual Plane (BMP), except U+0000:

ASCII: U+0001 .. U+007F

Extended: U+0080 .. U+FFFF

ASCII NUL (U+0000) and supplementary characters (U+10000 and higher) are not permitted in quoted or unquoted identifiers.

Identifiers may begin with a digit but unless quoted may not consist solely of digits.

Database, table, and column names cannot end with space characters."

Rules culled from this list of allowable characters: (1) ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) (2) Full Unicode Basic Multilingual Plane (BMP) except U+0000 (3) Identifiers may begin with a digit but unless quoted may not consist solely of digits. (4) Database, table, and column names cannot end with space characters.

Interpretation: Re: ASCII: See ASCII character chart from widipedia article on ASCII (https://en.wikipedia.org/wiki/ASCII#/media/File:USASCII_code_chart.png) shows that between 0000 (null character) and 007F (delete character) is the entire ASCII chart, meaning all 15 cols x 7 rows are legal to use in column names, which clearly contradicts the rules that only punctuation allowed is "$" and "_". For example, "#" is located at _4 (x axis) 2 (y axis) and has identifiers "0023" / "35". But "#" it appears to be excluded by the ascii rules anyway (it's punctuation that's not dollar or underscore), so it's not clear whether ASCII columns can include the "#". (BTW many ASCII charts are labeled differently and you cannot find correlation with any " _ _ _" numerical index so look for variations in table indexing if you can't find anything close to '0000' format.)

Re: UNICODE BMP: is indexed by U+_ _ _ _ so rules are easier to implement. For example, "#" appears in the full BMP as U+0023 so it should be OK to use (U+000 is the "null" character, BTW).

So it also appears that special characters allowed for column names varies based on collation in your database; UTF collations offer more options for special characters to be used in column names, another reason to prefer utf collation in your database, in addition to its ability to include more international characters, something more valuable when constructing a website with international membership.

MySQL Naming Rules, The following two queries use the same column names, but the context supplied by the FROM clause of each statement indicates which table to select the columns  Sure, we know that in our php coding we can specify which column name refers to which table (eg. cat.CatID, contact.CatID), but we kind of like the fact that our column naming conventions ensure


MySQL 8.0 Reference Manual :: 9.2 Schema Object Names, The following two queries use the same column names, but the context supplied by the FROM clause of each statement indicates which table to select the columns  Sensible and easy-to-understand table and column names make developing so much easier. MySQL Specific Notes. As a postscript, there are a few notes about naming things in MySQL. Since MySQL is case sensitive with table names on Linux, use Pascal casing (TransactionalEmails) and avoid lowercase and underscores


MYSQL Naming Conventions - Centizen Nationwide, Database, table, and column names cannot end with space characters. Elsewhere in the statement, quoted references to the alias must use identifier quoting  MySQL database naming conventions. There are coding standards on each programming language but in terms of MySQL I haven’t found any universal coding practice that everyone follows so i looked into different open source framework and popular PHP based software and found some generally applied standards on naming so I am trying to summaries it in this article.


Mysql table and column (field) naming conventions, MySQL is a freely available open source Relational Database for its quick processing, proven reliability, ease and flexibility of use. What is a naming convention? In computer programming, a naming convention is a set of rules for Foreign key column must have a table name with their primary key. The specific location is not important (or public). The key is that you CAN use numbers for table names. To further address the asker's question, one possible use would be that you have a master table where each row corresponds to a new table you created (And can have other information about the table) while also having an auto increment integer column that gives the integer for the table that