- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL Quoted table/field names vs unquoted names?
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)
Advertisements