Solved

error when creating table

Posted on 2004-10-15
6
265 Views
Last Modified: 2011-04-14
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
Comment
Question by:margotsk
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:minichicken
ID: 12326774
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
 
LVL 1

Expert Comment

by:NeonDevil
ID: 12331314
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
 

Author Comment

by:margotsk
ID: 12386927
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 12

Accepted Solution

by:
minichicken earned 500 total points
ID: 12387433
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
 

Author Comment

by:margotsk
ID: 12391178
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
 
LVL 12

Expert Comment

by:minichicken
ID: 12391789
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question