Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I keep getting this mysql error code #1089

Tags:

mysql

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?

like image 283
tinOfBeans Avatar asked May 22 '15 21:05

tinOfBeans


People also ask

How do I get out of MySQL error?

Just end the command with a semicolon ";". MySQL will display an error message and let you continue.

Why MySQL database is not connecting?

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.

Why do I keep losing connection to MySQL server?

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.

How do I Check my MySQL code for errors?

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.

Is it possible to correct my MySQL code?

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.

What is a MySQL 1064 error?

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.

Do you get an error message when writing SQL?

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.


1 Answers

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.

like image 51
dognose Avatar answered Sep 21 '22 11:09

dognose