Solved

error when creating table

Posted on 2004-10-15
6
261 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bubble user-defined Sql RAISERROR(...) to c# exception 14 145
PHP connection to remote AWS MySQL RDS 4 68
mcrypt_create_iv() is deprecated 4 70
PHP: concatenate query 12 38
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Creating and Managing Databases with phpMyAdmin in cPanel.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now