Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - Necessity of surrounding table name with ` (tickmarks)?

Tags:

mysql

In MySQL, is it necessary to surround tablenames with the tickmark? I've often seen code snippets that use the tickmarks, but I've not encountered a case where not surrounding a tablename with the tickmarks does anything different than with.


It looks like the framework I work with automatically parses reserved word keynames with tickmarks.

like image 697
ina Avatar asked Aug 09 '10 05:08

ina


1 Answers

The tickmarks are there to distinguish the table (or column!) names from SQL reserved words. For example, without the tickmarks, a table or column named update could clash with the SQL command update.

It's best practice not to name tables and columns with reserved words in the first place, of course, but if you port an application to a new database engine (or possibly even a new MySQL version), it might have a different set of reserved words, so you may have just broken your app anyway. The tickmarks are your insurance against this sort of oops.

like image 176
Nicholas Knight Avatar answered Sep 28 '22 02:09

Nicholas Knight