visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: Foriegn Key


By: Squibi U.S.A.  Date: 16/06/2003 00:00:00  English  Points: 30 Status: Answered
Quality : Excellent
Hi,
I m new to Mysql and i m trying to create database for my application.
In Mysql only InnoDB supports primay and reference key inetgrity.

I am able to create table with primay key
CREATE TABLE state (
stateId int NOT NULL UNIQUE,
name varchar(50),
PRIMARY KEY(stateId)
)TYPE=InnoDB;

But i am not able to create one more table which refers to the primary key of the table.
This is the query i have used.
CREATE TABLE worktype(
worktypeId int NOT NULL UNIQUE,
name varchar(100),
desc text,
stateId int NOT NULL REFERENCES state(stateId),
PRIMARY KEY(worktypeId)
)TYPE=InnoDB;

I am getting following error.
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc text,
stateId int NOT NULL REFERENCES state(stateId),
PRIM

What is problem with the query i have used.

Hope to see quick response you all.

Thank you

By: VGR Date: 16/06/2003 16:30:00 English  Type : Answer
DESC is a RESERVED keyword !!!

RTFM

Do register to be able to answer

EContact
browser fav
page generated in 291.129110 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page