CREATE TABLE `movies`.`movie` ( `movie_id` INT(3) NULL AUTO_INCREMENT, `movie_name` VARCHAR(25) NULL, `movie_embedded_id` VARCHAR(50) NULL, `rating_no` INT(3) NULL, `movie_description` VARCHAR(50) NULL, PRIMARY KEY (`movie_id`(3))) ENGINE = InnoDB;
I keep getting this error:
#1089 - Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys.
but I've got no idea what it means, anyone have a clue?
Just end the command with a semicolon ";". MySQL will display an error message and let you continue.
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
Open the MySQL Workbench Preferences. Check if the SSH Timeout and DBMS Timeout value is set to only a few seconds. Try to increase the default value of the connection timeouts. Save the settings, close the MySQL Workbench and reopen the connection to see if you are able to connect to the database.
An alternative to manually checking your work is to employ a tool such as EverSQL: With this solution, you can simply input your MySQL to check for errors automatically. However, keep in mind that these platforms aren’t always perfect and you may still want to validate the results yourself.
Unfortunately, they can also be the most tedious to correct. Generally speaking, your best option is to manually proofread your code and look for any mistakes you may have made. We suggest using the MySQL Manual as a reference while you do so, double-checking anything you’re not sure about.
Let’s get started! The MySQL 1064 error is a syntax error. This means the reason there’s a problem is because MySQL doesn’t understand what you’re asking it to do.
Instead, you get an error message. Don’t despair! Coding errors are common in any programming language, and SQL is no exception. In this post, we’ll discuss five common mistakes people make when writing SQL. The most common SQL error is a syntax error. What does syntax mean? Basically, it means a set arrangement of words and commands.
With the part
PRIMARY KEY (`movie_id`(3))
you are telling mysql to create a sub part key* on the first 3 Bytes of movie id. This only works for string types.
You need to use
PRIMARY KEY (`movie_id`)
without providing a length.
*Is this sure the query resulting in the error? Never saw that on a primary key, its used for indexes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With