Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do underscores in a MySQL table names cause issues?

Tags:

mysql

Do underscores in table names affect performance or cause issues on some platforms?

For example, user_profiles

Would it be better to use userProfiles or is it just a matter of personal preference?

like image 596
CyberJunkie Avatar asked Jul 09 '11 21:07

CyberJunkie


People also ask

Can we use underscore in table name in MySQL?

You cannot give underscore in table name. If you still want to create a new table with underscore, surround it using backticks, not single quotes.

Should table names have Underscores?

Rule 1d (Special Characters) - For table names, underscores should not be used. The underscore character has a place in other object names but, not for tables. Using PascalCase for your table name allows for the upper-case letter to denote the first letter of a new word or name.

Can I use underscore in database name?

The rules for naming database objects (such as tables, columns, views, and database procedures) are as follows: Names can contain only alphanumeric characters and must begin with an alphabetic character or an underscore (_). Database names must begin with an alphabetic character, and cannot begin with an underscore.

What are the rules for naming a table in MySQL?

By default, MySQL encloses column names and table names in quotation marks. Table names can use any character that is allowed in a file name except for a period or a forward slash. Table names must be 32 characters or less because SAS does not truncate a longer name.


1 Answers

Nope. Underscores are perfectly legal in table names.

This page here in the MySQL documentation tells you about what characters are allowed.

Basically:

Permitted characters in unquoted identifiers:

ASCII: [0-9,a-z,A-Z$_]
Extended: U+0080 .. U+FFFF

Permitted characters in quoted identifiers:

ASCII: U+0001 .. U+007F
Extended: U+0080 .. U+FFFF

Personally I tend to stick with lowercase a-z, the occasional number, and underscores. But as @Vince said, it's just personal preference.

like image 128
Ben Avatar answered Sep 23 '22 20:09

Ben