Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent user from creating tables and or databases with hyphens

Tags:

mysql

Is there way in MySQL to prevent someone from creating tables and/or databases with hyphens? (Other than striping privileges from the user.)

For example, if we have user IamADummy who wants to do this,

CREATE TABLE `I-am-a-bad-table-name`;

OR

CREATE DATABASE `Bad-Idea`;

Is there a setting that would stop the user from doing so?

Thanks!

like image 261
Anjisan Avatar asked Dec 30 '22 06:12

Anjisan


1 Answers

The only restrictions on table identifiers are as follows:

  • No identifier can contain ASCII NUL (0x00) or a byte with a value of 255.
  • Database, table, and column names should not end with space characters.
  • Database and table names cannot contain “/”, “\”, “.”, or characters that are not allowed in file names.

In order to have any other restrictions, you would have to examine the query in your system before running it and adjust it appropriately.

like image 93
zombat Avatar answered Apr 24 '23 22:04

zombat