When using PMA I often see that the program automatically wraps tables and variable names inside backticks. What is the meaning of this?
I have never used a backtick (I only wrap varchar, etc inside single or double quotes) and yet my MySQL runs fine???
What is this operator for in the context of MySQL? Is it escaping the table names, fields, etc?
backtick or quote?
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
That's exactly what it is.
Database, table, index, column, and alias names are "identifiers" in SQL, which are escaped with backticks. It's similar to the :symbol in Ruby - it takes the guesswork out of the parser that the string might be just a string.
I got into the habit of always quoting everything, just to be safe. I think it cost me a few debugging hours once... now I'm twice shy.
Database, table, index, column, and alias names are "identifiers" in SQL, which are escaped with backticks. It's similar to the :symbol in Ruby - it takes the guesswork out of the parser that the string might be just a string.
I got into the habit of always quoting everything, just to be safe. I think it cost me a few debugging hours once... now I'm twice shy.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
It's not really about making it easier for the parser… It's intention is to remove errors due to bad naming choices. People tend to use field and table names which are keywords; few of which MySQL will accept as not a keyword in the contextual use. Provided you do not use keywords as table and field names, you're fine and don't need to use them.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Ah yes....now I recall having read that sometime ago.feyd wrote:It's not really about making it easier for the parser… It's intention is to remove errors due to bad naming choices. People tend to use field and table names which are keywords; few of which MySQL will accept as not a keyword in the contextual use. Provided you do not use keywords as table and field names, you're fine and don't need to use them.
Thanks