LoginSignup
0
0

More than 1 year has passed since last update.

MySQL | Use non-alphanumeric characters and underscores in backquotes when using anything other than underscores in database names / table names

Last updated at Posted at 2019-04-16

I can not create a database

For example, I want to create a database with a hyphenated name. But even if it writes like this.

 mysql> CREATE DATABASE example; 

It is useless.

 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 '-xample' at line 1 

MySQL does not give me any kind of errors.

Alphanumeric characters and underscores

When using characters other than "alphanumeric characters" and "under bar" , enclose them with back quotes.

 mysql> CREATE DATABASE `example`; 

 Query OK, 1 row affected (0.01 sec) 

Other. It will work well if you enclose it in a back quote.

 CREATE DATABASE `example`; CREATE DATABASE `e/x/a/m/p/l/e`; CREATE DATABASE `e*x*a*m*p*l*e`; CREATE DATABASE `えぐざんぷる`; 

exception

If there is a space at the beginning or end, it is considered an invalid name. It was impossible even if it enclosed with a back quote.

 CREATE DATABASE ` example `; 

 ERROR 1102 (42000): Incorrect database name ' example ' 

Original by

MySQL | 英数字以外とアンダーバー 以外をデータベース名 / テーブル名に使う時はバッククォートで囲う

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0