1

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!)

2 Answers 2

2

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 , 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Besides this, I've also had to add primary_key(koncert_id). Now it's working.
0

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

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.