Home > Database > Mysql Tutorial > Can underscores in MySQL table names cause problems?

Can underscores in MySQL table names cause problems?

王林
Release: 2023-09-03 22:41:06
forward
1303 people have browsed it

MySQL 表名中的下划线会导致问题吗?

No, there are no problems with underscores in MySQL table names. Dashes in MySQL table names can cause problems.

This is a demo, there is no problem with underscores in table names -

_StudentTrackerDemo
Copy after login

Let us see the same while creating the table. The query to create the table is as follows -

mysql> create table _StudentTrackerDemo
   -> (
   -> StudentId int,
   -> StudentFirstName varchar(100)
   -> );
Query OK, 0 rows affected (0.75 sec)
Copy after login

Underscores are valid for table names, but dashes are not valid in some MySQL versions. This is the table name with a dash. The same error occurs -

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
Copy after login

The above is the detailed content of Can underscores in MySQL table names cause problems?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template