mariadb

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!?

SQL NULL-SAFE

Written by  on August 6, 2019

Liefert keine Felder zurück, wo eines oder beide Felder NULL sind:

select usr_id from usr_data where (usr_data.a != usr_data.b);

NULL-SAFE – schlägt auch an, wenn eines der Felder NULL ist:

select usr_id from usr_data where NOT (usr_data.a <=> usr_data.b);

MariaDB Doku