Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Can a number be used to name a MySQL table column?
Yes, we can include a number for column name in MySQL. We need to use the symbol backtick, which is as follows
( ` `)
To understand, we will make a table with the help of CREATE command. Let us create a table −
mysql> CREATE table NumberColumnDemo -> ( -> `123` varchar(100) -> ); Query OK, 0 rows affected (0.51 sec)
Above, I have created a column name as a number with the help of backtick symbol.
Now, we can check the same by inserting records with the help of INSERT command. Let us insert a record, which is as follows −
mysql> INSERT into NumberColumnDemo values('45678');
Query OK, 1 row affected (0.20 sec)
After that, we can display all the records with the help of SELECT statement. The query is as follows −
mysql> SELECT * from NumberColumnDemo;
The following is the output −
+-------+ | 123 | +-------+ | 45678 | +-------+ 1 row in set (0.00 sec)
Advertisements
