0

this might end in a down vote but I can´t see trees because of forest:

running this sql query:

CREATE TABLE `fontFamilies` (
  `id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
  `name` VARCHAR NOT NULL DEFAULT 'NULL',
  `designer` INTEGER NULL,
  `firstLaunch` TIMESTAMP NULL DEFAULT NULL,
  `lastUpdate` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
); 

I get following error in http://sqlfiddle.com/

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 'NOT NULL DEFAULT 'NULL',
  `designer` INTEGER NULL,
  `firstLaunch` TIMESTAMP NU' at line 3

What is causing this error?

3
  • It works in sql fiddle. Are you sure? Commented Jun 14, 2015 at 11:19
  • @marc_s, in error there is mysql, and I can not reproduce this error on sqlfiddle Commented Jun 14, 2015 at 11:24
  • @GiorgiNakeuri copy paste does not work... Commented Jun 14, 2015 at 11:30

2 Answers 2

4

SQLFiddle uses mysql. Try setting the size of varchar:

CREATE TABLE `fontFamilies` (
  `id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
  `name` VARCHAR(100) NOT NULL DEFAULT 'NULL',
  `designer` INTEGER NULL,
  `firstLaunch` TIMESTAMP NULL DEFAULT NULL,
  `lastUpdate` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
); 

You can also add insert commands to the same window:

insert into `fontFamilies` values(217,'name',217,'1992-10-10 10:10:10','1992-10-10 10:10:10')
Sign up to request clarification or add additional context in comments.

4 Comments

I didn't downvote, but I don't think you need to explicitly set the varchar length. It defaults (I think) to 255.
@AlvinThompson you can try it in SQL Fiddle (with mysql) and see if that true
I guess that's it! Is that mysql specific?
@AlvinThompson I think so
1

You must set the size of VARCHAR .

    CREATE TABLE `fontFamilies` (
  `id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
  `name` VARCHAR(30) NOT NULL DEFAULT 'NULL',
  `designer` INTEGER NULL,
  `firstLaunch` TIMESTAMP NULL DEFAULT NULL,
  `lastUpdate` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
  );

This will work .

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.