Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

error when creating table

Hi,
I encounter an error when creating tables with PRIMARY KEY. The error is as fallows:
"Data base created succesfulyYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY (movie_id), KEY movie_type (movie_type,movie_year) ) TYPE"
My current mysql version is 4.0.21
Any Ideas?
Thank's
M
0
margotsk
Asked:
margotsk
  • 3
  • 2
1 Solution
 
minichickenCommented:
Hi

What are you using to creat your table? PHPMyAdmin or some kind?
If you would like to create a table with PRIMARY key, it need to have syntax like this.....

CREATE TABLE `movie` (
`movie_id` INT NOT NULL AUTO_INCREMENT ,
`movie_type` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `movie_id` )
);

Hope this help...
0
 
NeonDevilCommented:
It may be easier to install and use a mySQL utility, I would suggest either mySQL Control Center (http://dev.mysql.com/downloads/other/mysqlcc.html) or mySQL Query Browser (http://dev.mysql.com/downloads/query-browser/index.hml)

Also, double check your syntax for your CREATE TABLE command:
http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html
0
 
margotskAuthor Commented:
Thank's for responding,
The code is as follows:
$movie="CREATE TABLE movie (
movie_id INT(11) NOT NULL AUTO_INCREMENT,
movie_name VARCHAR(255) NOT NULL,
movie_type TINYINT(2) NOT NULL DEFAULT 0,
movie_year INT(4) NOT NULL DEFAULT 0,
movie_leadactor INT(11) NOT NULL DEFAULT 0,
movie_director INT(11) NOT NULL DEFAULT 0,
PRIMERY KEY (movie_id),
KEY movie_type (movie_type,movie_year)
) TYPE=MyISAM AUTO_INCREMENT=4 ";

I am learing MySQL from book "Beginning PHP,Apache,MySQL Web development" and I am at beging of chapter that covers MySQL topic. Through google in another forum i found some one else using the same book and having exaclty the same problem in the same code. She never posted, how she did solve it. That make's me thing that there is some typo or syntex mistake which i, as begginer, do not see. It is certanly some thing to do with line [KEY movie_type....] I went trought the manual that NeonDevil listed, but everything seems correct.
Thank's
m
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
minichickenCommented:
Hi

I found the error, there is a typo with the word PRIMERY >> it should be PRIMARY, it works fine, i test it...

Here is the correct syntax:

CREATE TABLE movie(
movie_id INT( 11 ) NOT NULL AUTO_INCREMENT ,
movie_name VARCHAR( 255 ) NOT NULL ,
movie_type TINYINT( 2 ) NOT NULL DEFAULT 0,
movie_year INT( 4 ) NOT NULL DEFAULT 0,
movie_leadactor INT( 11 ) NOT NULL DEFAULT 0,
movie_director INT( 11 ) NOT NULL DEFAULT 0,
PRIMARY KEY ( movie_id ) ,
KEY movie_type( movie_type, movie_year )
) TYPE = MYISAM AUTO_INCREMENT =4


regards-
0
 
margotskAuthor Commented:
Thank's a lot...and also thank you for making me look so silly..ha, ha
All points are yours
All the Best,
m
0
 
minichickenCommented:
no prob :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now