16

I couldn't find anything on google, maybe I am not searching the correct term. But is there a list of not allowed character for column names in mysql database ? I am particularly interested in the $ sign.

StudentX
  • 2,243
  • 6
  • 35
  • 67

1 Answers1

22

Extracted from the MySQL docs assuming you are using at least MySQL 5.0 or higher:

Permitted characters in unquoted identifiers:

  • ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)

  • Extended: U+0080 .. U+FFFF

Permitted characters in quoted identifiers include the full Unicode Basic Multilingual Plane (BMP), except U+0000:

  • ASCII: U+0001 .. U+007F

  • Extended: U+0080 .. U+FFFF

TL;DR

Answering your question, yes.. You can use the $ character in column names quoted or unquoted.

Brandon White
  • 997
  • 9
  • 22
  • If this is true for quoted identifiers, then why is this giving me a duplicate value error: col1 ENUM('VŠS', 'VSS') ? Seems that only ASCII is allowed here... – TomoMiha Apr 24 '20 at 08:41
  • 2
    @TomoMiha I think you are confusing `collation config` with `permitted characters`. Take a look at this question for more details: https://stackoverflow.com/questions/34387766/use-accent-senstive-primary-key-in-mysql – Brandon White Apr 26 '20 at 12:43
  • Thanks, I found in the meanwhile that I had to change that COLLATION thing from ut8mb4_unicode_ci to utf8mb4_bin to make it work – TomoMiha Apr 27 '20 at 07:37