Please help sort out a syntax error when I try to define a MySQL table

The error is this;

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''order'(
 orderID VARCHAR(6) NOT NULL DEFAULT 0,
 orderDate DATE NOT NULL DEFAUL' at line 1 

My DDL is this:

CREATE TABLE 'order'(
orderID VARCHAR(6) NOT NULL DEFAULT 0,
orderDate DATE NOT NULL DEFAULT 1,
claimCondition VARCHAR(30) NOT NULL DEFAULT ''
);

Answers


The name order is a reserved word, so you'll have to name the table something else. Also, the value 1 isn't a valid default for the type date.

This works:

CREATE TABLE order1 (
    orderID VARCHAR(6) NOT NULL DEFAULT 0,
    orderDate DATE NOT NULL,
    claimCondition VARCHAR(30) NOT NULL DEFAULT ''
);

CREATE TABLE `order`(
`orderID` VARCHAR(6) NOT NULL DEFAULT 0,
`orderDate` TIMESTAMP  NOT NULL DEFAULT CURRENT_TIMESTAMP,
`claimCondition` VARCHAR(30) NOT NULL DEFAULT ' '
);

You cant assign default 1 to the date field ,since the data type is date the default value must be the date value(use a default date or Current date instead)

      create table orders(orderId varchar(6 ) NOT NULL DEFAULT 0,order_Date DATE NOT NULL DEFAULT "0000-00-00",claimCondition VARCHAR(30) NOT NULL DEFAULT '');

The above query is working know without default value to the date field

Refer this link you will get the idea of datatypes and and its default values http://kimbriggs.com/computers/computer-notes/mysql-notes/mysql-data-types-50.file


Need Your Help

How can I get a reference to the currently selected text in keynote into a variable in applescript

applescript keynote

I would really like to drop MS Office and switch to the Apple apps but I have some applescripts for powerpoint that I need to replace. I need to do things like change the font or the opacity of the

How to load ruby file in the pry editor?

ruby pry

I use pry with the standard editor vi.