- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Do underscores in a MySQL table name cause issues?
No, you won’t get any issues with underscores in a MySQL table name. You will get the issues with a dash in a MySQL table name.
Here is the demo that does not have any issue with underscore with table names −
_StudentTrackerDemo
Let us see the same while creating a table. The query to create a table is as follows −
mysql> create table _StudentTrackerDemo -> ( -> StudentId int, -> StudentFirstName varchar(100) -> ); Query OK, 0 rows affected (0.75 sec)
The underscore is valid for table names but dash is not valid in some MySQL versions. Here is the table name with dash. The same gives an error −
mysql> create table Student-table -> ( -> Id int, -> Name varchar(100) -> ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-table (Id int, Name varchar(100) )' at line 1
- Related Articles
- Why do some Python functions have underscores "__" before and after the function name?
- Underscore as a table name in MySQL is possible?
- Can we give underscore in a MySQL table name?
- How do I detect if a table exist in MySQL?
- Can we create a table with a space in name in MySQL?
- How do I verify that a string only contains letters, numbers, underscores and dashes in Python?
- What is the maximum length of a table name in MySQL?
- How do I alter a MySQL table column defaults?
- How do I list all the columns in a MySQL table?
- How do I show unique constraints of a table in MySQL?
- How do I clone the structure of a table in MySQL?
- How do I add a check constraint to a table in MySQL?
- MySQL show tables sort by table name?
- How can we change the name of a MySQL table?
- Can a number be used to name a MySQL table column?

Advertisements