0

I try to import sql file to my database. the query is :

CREATE TABLE 'project' (
  `id`              int(11) NOT NULL AUTO_INCREMENT,
  `name`            varchar(255) NOT NULL,
  `description`     text NOT NULL,
  `creat_time`      datetime DEFAULT NULL,
  `create_user_id`  int DEFAULT NULL,
  `update_time`     datetime DEFAULT NULL,
  `update_user_id`  INTEGER DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

The error information is :

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 ''project' ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(25' at line 1)

But I did not see any errors from my query. Anyone can give me advises?

1
  • create_time would be better than creat_time Commented Nov 7, 2013 at 15:46

1 Answer 1

1

Remove the singlequotes ( ' ) around table name ( 'project' ):

CREATE TABLE project (
  `id`              int(11) NOT NULL AUTO_INCREMENT,
  `name`            varchar(255) NOT NULL,
  `description`     text NOT NULL,
  `creat_time`      datetime DEFAULT NULL,
  `create_user_id`  int DEFAULT NULL,
  `update_time`     datetime DEFAULT NULL,
  `update_user_id`  INTEGER DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

SQLFIDDLE DEMO

Single quotes are used for string values. There you can use ` backticks if you want, but you might as well don't use anything.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.