MySQL - Need a table surrounding name with `(tickmarks)?

In MySQL, is it necessary to surround tablenames with ticks? I often saw code snippets that use labels, but I have not seen a case where not surrounding tablename with ticks does nothing else than with.


It looks like the wireframe I'm working with automatically analyzes reserved keywords with keywords.

+7
mysql
source share
4 answers

Keys for distinguishing table names (or columns!) From SQL reserved words. For example, without labels, a table or column named update may encounter the SQL update command.

It’s best not to specify names and columns with reserved words, first of all, of course, but if you transfer the application to a new database engine (or, possibly, even a new version of MySQL), it may have a different set of reserved words, so you maybe just broke your app. Keys are your insurance against this kind of oops.

+8
source share

In case the table or column names use mySQL keywords ,

+6
source share

This is only necessary if your table name is made up of characters other than a "word" (that is: nothing but letters, numbers and underscores), or it can be the same as the keyword in MySQL. It is never "bad" to quote a name, but it is bad if you need to, so many programs that generate MySQL queries will be conservative and quote the name - it's just easier.

+2
source share

I once worked at work, where they had a database of "locations." They called it states. and everything in the tables, each table was called a status code. therefore, Missouri was MO, and Arkansas was AR.

Several status codes are also reserved words OR (Oregon) and IN (Indiana) and ON (Ontario) ... I do not know the exact state.

Even if I think that there were better ways to organize the database data, there are times when people want to call things a reserved word. This is an example in which the symbol `` stores the stored code.

+2
source share

All Articles