Nistor Alexandru
Nistor Alexandru

Reputation: 5393

Syntax error in SQL create table

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?

Upvotes: 0

Views: 5359

Answers (3)

VeZoul
VeZoul

Reputation: 510

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

Upvotes: 1

Saasu Ganesan
Saasu Ganesan

Reputation: 180

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;

Upvotes: 4

Bhavik Shah
Bhavik Shah

Reputation: 5183

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

Upvotes: 2

Related Questions