0

Hi I am trying to get more familiat with SQL and I am using MySql to test my SQL queries.I seem to be getting a sintax error in this statement:

CREATE TABLE dog
(
  id int(11) NOT NULL auto_increment,
  name varchar(255),
  descr text,
  size enum('small','medium','large'),
  date timestamp(14),
  PRIMARY KEY (id)
)ENGINE = InnoDB;

Error:

#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 '(14), PRIMARY KEY (id) )ENGINE = InnoDB' at line 7

What am I doing wrong here?

3
  • Remove (11) from your query just use id int NOT NULL auto_increment, Commented Oct 18, 2012 at 9:58
  • 2
    Change: timestamp(14) -> timestamp Commented Oct 18, 2012 at 9:59
  • I hope it should be an warning in statement it not an error:) Commented Oct 18, 2012 at 10:03

3 Answers 3

4

try mentioning like this

CREATE TABLE dog

(
  id int NOT NULL auto_increment,
  name varchar(255),
  descr text,
  size enum('small','medium','large'),
  date timestamp,
  PRIMARY KEY (id)
)
ENGINE = InnoDB;
Sign up to request clarification or add additional context in comments.

Comments

2

'TIMESTAMP(14)' is deprecated; use 'TIMESTAMP' instead

Comments

1

Try this :

CREATE TABLE dog

(
  id int NOT NULL auto_increment PRIMARY KEY,
  name varchar(255),
  descr text,
  size enum('small','medium','large'),
  date timestamp
)
ENGINE = InnoDB;

PRIMARY KEY statement has to be precised with the field declaration

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.