Search code examples
mysqlsqlddlcreate-table

Create SQL table with SQL keyword column


I am trying to create SQL table with SQL keyword column named "lock", but "lock" seems is a SQL keyword where the workbench thought I would want to execute the "lock" function.

Create table A(
Lock Varchar(255)
);

*Putting the "Lock" into a square bracket --> [lock] doesn't work for me.


Solution

  • MySQL uses the ` character to escape object names:

    Create table A(
        `Lock` Varchar(255)
    );