Bernard Polman
Bernard Polman

Reputation: 855

SQL syntax error

I use phpMyAdmin and want to create a table. I use the visual interface for creating the table but I'm gonna post the code from "Preview SQL" option:

CREATE TABLE `baza`.`koncert` ( 
    `koncert_id` INT(10) NOT NULL AUTO_INCREMENT , 
    `koncert_naziv` VARCHAR(50) NULL , 
    `koncert_lokacija` VARCHAR(50) NOT NULL , 
    `koncert_datum` DATE NULL DEFAULT NULL , 
    `koncert_cijena` DOUBLE(10) NOT NULL , 
    `koncert_slika` VARCHAR(500) NOT NULL ) 
ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_croatian_ci;

And I get this error:

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL version for the right syntax to use near ')' NOT NULL, 'koncert_slika' VARCHAR(500) NOT NULL ) ENGINE=InnoDB CHARSET=ut

I tried setting the 'koncert_datum' default value to CURRENT_TIMESTAMP, but then I get an error "Invalid default value for 'koncert_datum'". I just don't understand what could possibly be wrong (and I used the phpMyAdmin visual interface to try create the table!)

Upvotes: 1

Views: 174

Answers (2)

javier
javier

Reputation: 106

According to the documentation https://dev.mysql.com/doc/refman/5.7/en/floating-point-types.html the DOUBLE type needs total digits and decimal digits. Something like

`koncert_cijena` DOUBLE(12,2) NOT NULL , 

Upvotes: 2

Mithunram
Mithunram

Reputation: 48

Check the schema and ensure baza.koncert is present and try running them by removing "ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_croatian_ci" this.

Upvotes: 0

Related Questions