Databases :: MySql :: Foriegn Key |
|||
| By: Squibi |
Date: 16/06/2003 00:00:00 |
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 | Type : Answer |
|
| DESC is a RESERVED keyword !!! RTFM |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








