
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
While creating a MySQL table use the reserved keyword ‘Key’
To use the reserved keyword ‘Key’, use the concept of the backtick symbol. Here, for our example, I am using the column name key which needs a backtick symbol around the column name.
Let us first create a table −
mysql> create table DemoTable ( `Key` int ); Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(101); Query OK, 1 row affected (0.55 sec) mysql> insert into DemoTable values(110); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values(120); Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+ | Key | +------+ | 100 | | 101 | | 110 | | 120 | +------+ 4 rows in set (0.00 sec)
- Related Articles
- What is the MySQL syntax error in this query – Creating a table with reserved keyword?
- Can we use {} while creating a MySQL table?
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- What is MySQL GENERATED COLUMN and how to use it while creating a table?
- Set AUTO_INCREMENT in a table while creating it in MySQL?
- Creating Unique Key in MySQL table referring to date?
- Set DEFAULT values for columns while creating a table in MySQL
- Set options while creating a MySQL table. Display the same options as well
- How can I define a column of a MySQL table PRIMARY KEY without using the PRIMARY KEY keyword?
- Will “create table table” work in MySQL since we cannot use reserved words as table name?
- How can we use logical operators while creating MySQL views?
- What is the use of MySQL BINARY keyword while performing string comparison?
- Fix Error in MySQL syntax while creating a table column with name “index”?
- How to resolve the error that occurs while using a reserved word as a table or column name in MySQL?
- How can we use a combination of logical operators while creating MySQL views?

Advertisements