Search code examples
mysqldatabasedatabase-schema

SQL bad attribute (column) names


I've created table in MySQL database with the query:

CREATE TABLE IF NOT EXISTS `CREW` (
`ID` INT NOT NULL,
`CALL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`ID`));

And it did work perfectly, but when I tried to:

INSERT INTO CREW (ID, CALL) VALUES (0, 'None');

I've got ERROR 1064. What are the other bad names for attributes that we should avoid?


Solution

    1. Don't use reserved words for column names. MySQL list here: https://dev.mysql.com/doc/refman/8.0/en/keywords.html. Multi-db list here: https://www.drupal.org/node/141051

    2. If you want your SQL to be compatible with other databases, you should use snake_case