Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

don't use "Keywords and Reserved Words" / Wildcards in schema #94

Open
GETandSELECT opened this issue May 14, 2018 · 0 comments
Open

don't use "Keywords and Reserved Words" / Wildcards in schema #94

GETandSELECT opened this issue May 14, 2018 · 0 comments

Comments

@GETandSELECT
Copy link

Hey

In MariaDB and MySQL (and every other relation database) there are reserved keywords, which shouldn't be used in schema (table names, column names, etc).

https://dev.mysql.com/doc/refman/8.0/en/keywords.html

Please also don't use wildcards (underscore is a wildcard) in schema. Confusion par excellence ;)

MariaDB [osbdb]> desc service_detail;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| _key       | varchar(255) | YES  |     | NULL    |                |
| _type      | varchar(255) | YES  |     | NULL    |                |
| unique_key | bit(1)       | NO   |     | NULL    |                |
| _value     | varchar(255) | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

you use here _key and _type.

Nisi made a query and wondered why empty result set

MariaDB [osbdb]> select * from service_detail WHERE "_type" = "port" limit 4;
Empty set (0.00 sec)

it needs special quoting:

MariaDB [osbdb]> select * from service_detail WHERE `_type` = "port" limit 4;
+-----+------+-------+------------+--------+
| id  | _key | _type | unique_key | _value |
+-----+------+-------+------------+--------+
|  44 | port | port  |            | 30591  |
|  89 | port | port  |            | 38945  |
| 143 | port | port  |            | 27234  |
| 173 | port | port  |            | 39628  |
+-----+------+-------+------------+--------+
4 rows in set (0.00 sec)

thanks
GETandSELECT

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant