1

I know there are a bunch of questions with this subject but I haven't found my mistake here. I've just started learning SQL.

My query:

CREATE TABLE IF NOT EXISTS `data` (
  `id` int(11) NOT NULL auto_increment,
  `quizid` int(11) NOT NULL default '0',
  `result` int(3) NOT NULL default '0',
  `IP` varchar(16) NOT NULL default '',
  `ts` timestamp(14) NOT NULL,
  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) NOT NULL,
  PRIMARY KEY  (`id`)' at line 6

I know the answer must be easy to spot by the right eyes.

2 Answers 2

4

timestamp does not accept length in CREATE TABLE clause

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

Comments

3

timestamp accepts length but upto 6 precision numbers. But then you need not specify length for timestamp

3 Comments

dev.mysql.com/doc/refman/5.5/en/create-table.html does it? It's not specified in the CREATE TABLE syntax :-S
Tried with TIMESTAMP(2). It was executed as if the length wasn't specified at all
you can if you specify the default value as none but then that doesn't make much of sense..

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.