MySQL Quoted table/field names vs unquoted names?

MySQLMySQLi Database

Any identifiers like tablename, stored procedure, viewname or column etc. may be quoted or unquoted. When an identifier is a reserved keyword then you must quote it, else an error would occur.

Let us first create a table. Here, we have taken field names as reserved keywords −

mysql> create table `INT` (`select` int,`varchar` varchar(100));
Query OK, 0 rows affected (0.50 sec)

Insert some records in the table using insert command −

mysql> insert into `INT` values(1,'MySQL');
Query OK, 1 row affected (0.14 sec)
mysql> insert into `INT` values(2,'MongoDB');
Query OK, 1 row affected (0.34 sec)
mysql> insert into `INT` values(3,'Java');
Query OK, 1 row affected (0.15 sec)
mysql> insert into `INT` values(4,'C');
Query OK, 1 row affected (0.19 sec)

Display all records from the table using select statement −

mysql> select *from `INT`;

This will produce the following output −

+--------+---------+
| select | varchar |
+--------+---------+
|      1 | MySQL   |
|      2 | MongoDB |
|      3 | Java    |
|      4 | C       |
+--------+---------+
4 rows in set (0.00 sec)
raja
Published on 22-Aug-2019 12:40:38
Advertisements