Sunday, February 28, 2010

order is a reserved word in SQL

I'm not sure if this was ever mentioned in class or anything, but "order" is a reserved word in SQL, so you cannot (in MySQL, anyway) create a table named "order". The error I was getting when I was attempting to do this was not very clear, so it took a while to realize that this was the problem.

So, if any of you run into this, renaming the table to something like "customer_order" should work fine.

3 comments:

  1. That's interesting, because I created a table in MySQL that's called "order" and it works just fine for me.

    ReplyDelete
  2. yeah I had to call mine orders.

    ReplyDelete
  3. It is possible to create a table named order. If you simply run command such as
    create table order (.......);
    you will run into exception.

    However putting order within quotes should work. Note that this is not a single quote though. If you want to try it yourself, I would recommend you to copy and paste it.
    create table `order` (.........);

    ReplyDelete