Solved

error when creating table

Posted on 2004-10-15
6
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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