
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Can we create a table with a space in name in MySQL?
To create a table with a space in the table name in MySQL, you must use backticks otherwise you will get an error.
Let us first see what error will arise by creating a table with a space in the name i.e. “Demo Table” table name below:
mysql> create table Demo Table ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeFirstName varchar(20), EmployeeLastName varchar(20), EmployeeAge int, EmployeeSalary int, EmployeeAddress varchar(200) ); ERROR 1064 (42000): You have an error in your syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Table37 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeFirstName varchar(' at line 1 )
Let us use the concept of backticks for table name to remove the error. The query to create a table with a space in MySQL is as follows:
mysql> create table `Demo Table37` ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeFirstName varchar(20), EmployeeLastName varchar(20), EmployeeAge int, EmployeeSalary int, EmployeeAddress varchar(200) ); Query OK, 0 rows affected (0.66 sec)
Above, we have set the table name with space surrounded by backtick symbol, therefore no error:
`Demo Table37`
- Related Questions & Answers
- Can we create a database with a numeric name with MySQL?
- Can we give underscore in a MySQL table name?
- How can we change the name of a MySQL table?
- How can create a table having the name like a^b along with same column name? name?
- How can we create a table from an existing MySQL table in the database?
- How can we create a MySQL view with a subquery?
- How can we create a MySQL table by using PHP script?
- How can we have multiple virtuals GENERATED COLUMNS in MySQL table with CREATE TABLE statement?
- How can we update values in a MySQL table?
- How can we create a MySQL temporary table by using PHP script?
- Can we add a column to a table from another table in MySQL?
- How can we create a MySQL view with LEFT JOIN?
- How can we create a MySQL view with INNER JOIN?
- How can we create a MySQL view with RIGHT JOIN?
- How can we make a MySQL clone table?
Advertisements