🖥
MySQL | Use non-alphanumeric characters and underscores in backquotes
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
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2019-04-16
Discussion