Home > Database > Mysql Tutorial > body text

Can I Use Dots in MySQL Database Names?

DDD
Release: 2024-10-31 00:40:03
Original
597 people have browsed it

Can I Use Dots in MySQL Database Names?

Creating Databases with Dots in MySQL

Can MySQL databases contain dots in their names? This article addresses this question, particularly for MySQL version 5.1.22.

Answer:

The answer is no, MySQL does not allow creating databases with dots in their names. It is generally advisable to avoid using dots in any identifier, including database and field names. The preferred alternative is the underscore character, which serves the same purpose without causing confusion.

However, there may be instances where you have a compelling reason to use unusual characters in a table or field name. In such cases, you can escape the identifier using the backtick character:

CREATE DATABASE `my.database`;
CREATE TABLE `my_table` (`my.field` INT);
Copy after login

By escaping the identifier with backticks, you can include characters that are otherwise illegal in database and field names. It is also considered good practice to consistently escape all field names with backticks, regardless of necessity.

The above is the detailed content of Can I Use Dots in MySQL Database Names?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!