Repository: tobymao/sqlglot

Issue:
Parsing columns with reserved names
I often find cases when databases use reserved words as a column name, for example `left` or `key`. Reserved words are permitted as identifiers if you quote them. The library cannot parse such syntax.

**Fully reproducible code snippet**
```python
    sql = """
        CREATE TABLE `oauth_consumer` (
            `key` varchar(32) NOT NULL,
            UNIQUE KEY `OAUTH_CONSUMER_KEY` (`key`),
        );
    """
    parsed_sql_exprs = sqlglot.parse(sql, read="mysql")
```

**Official Documentation**
[Please include links to official SQL documentation related to your issue.](https://dev.mysql.com/doc/refman/8.0/en/keywords.html)


Discussion:

Patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 76b6ee51..58b9a1a5 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -3892,7 +3892,9 @@ class Parser(metaclass=_Parser):
     def _parse_unnamed_constraint(
         self, constraints: t.Optional[t.Collection[str]] = None
     ) -> t.Optional[exp.Expression]:
-        if not self._match_texts(constraints or self.CONSTRAINT_PARSERS):
+        if self._match(TokenType.IDENTIFIER, advance=False) or not self._match_texts(
+            constraints or self.CONSTRAINT_PARSERS
+        ):
             return None
 
         constraint = self._prev.text.upper()


Test patch:
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py
index 11f921ce..14a864be 100644
--- a/tests/dialects/test_mysql.py
+++ b/tests/dialects/test_mysql.py
@@ -29,6 +29,9 @@ class TestMySQL(Validator):
         self.validate_identity("CREATE TABLE foo (a BIGINT, INDEX USING BTREE (b))")
         self.validate_identity("CREATE TABLE foo (a BIGINT, FULLTEXT INDEX (b))")
         self.validate_identity("CREATE TABLE foo (a BIGINT, SPATIAL INDEX (b))")
+        self.validate_identity(
+            "CREATE TABLE `oauth_consumer` (`key` VARCHAR(32) NOT NULL, UNIQUE `OAUTH_CONSUMER_KEY` (`key`))"
+        )
         self.validate_identity(
             "CREATE TABLE `x` (`username` VARCHAR(200), PRIMARY KEY (`username`(16)))"
         )