How to Use Reserved Words as Identifiers
Suppose you have used reserved keywords as identifiers, then it will return the syntax error. For using reserved words as identifiers, it should be enclose in backticks(`). MySQL understands that it should be treated as a user-defined identifier rather than a reserved word.
Example
CREATE TABLE MyTable
(
order_id INTEGER,
`GROUP` INTEGER,
`Table` INTEGER
);
In the above query , we have used two reserved words GROUP and TABLE. for using this reserved key words as identifiers we have enclosed them in backticks(`).
Query:
DESCRIBE MyTable;
Output:
Field |
Type |
Null |
Key |
Default |
---|---|---|---|---|
order_id |
int |
YES |
NULL |
|
GROUP |
int |
YES |
NULL |
|
Table |
int |
YES |
NULL |
Explanation: As shown in the above table, We have created a table where column name is reserved words. For this, we have used backticks(`).
MySQL Reserved Words
MySQL is a popular and widely used Relational Database Management System. Like any programming language, MySQL has its own set of reserved words. Reserved words are specific terms or keywords with predefined meanings within the database system. It is very important to know the reserved words to avoid conflicts in the execution of the queries.
Contact Us