Home Why does this script fail because it doesn't like the column name?
Reply: 1

Why does this script fail because it doesn't like the column name?

nicomp
1#
nicomp Published in 2018-01-12 23:20:34Z

This question already has an answer here:

  • Syntax error due to using a reserved word as a table or column name in MySQL 1 answer

It doesn't like the word release as a column name.

 CREATE TABLE external_db (

      external_db_id          INT not null,
      db_name                     VARCHAR(100) NOT NULL,
      release                    VARCHAR(40)  NOT NULL,
      status                      ENUM ('KNOWNXREF','KNOWN','XREF','PRED','ORTH', 'PSEUDO') not null,

      PRIMARY KEY( external_db_id ) 

    );

I changed the field name to releaseX and the error went away.

This script came from https://github.com/Ensembl/ensembl/blob/release/91/sql/table.sql, which is supposed to be mySQL. Is this a versioning issue in MySQL or can I decorate the word release in the script so it can be used as a column name?

I am using MySQL 5.7 and MySQLWorkbench 6.3.

I know release is a bad name for a column but I didn't write the script.

rlanvin
2#
rlanvin Reply to 2018-01-12 23:23:24Z

Release is a reserved keyword

To use it as a column name, you can escape it with backticks like this:

`release`
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311756 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO