MariaDB Create Database

Written by  on Oktober 23, 2019 

Eine Datenbank anlegen geht ganz einfach

MariaDB [(none)]> create database db1;
Query OK, 1 row affected (0.001 sec)

Außer es soll ein Bindestrich im Datenbanknamen vorkommen

MariaDB [(none)]> create database db-1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-1' at line 1

Vielleicht helfen Anführungszeichen

MariaDB [(none)]> create database "db-1";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"db-1"' at line 1

Oder einfache Hochkommata

MariaDB [(none)]> create database 'db-1';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''db-1' at line 1

Oder mit einem Schrägstrich quotieren

MariaDB [(none)]> create database 'db\-1';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''db\-'' at line 1

Oder so was

MariaDB [(none)]> create database ´db-1´;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-1´' t line 1

Nein, es müssen Backticks sein

MariaDB [(none)]> create database `db-1`;
Query OK, 1 row affected (0.001 sec)

Ist doch logisch!?

Category : Allgemein

Tags :

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.