18 messages in com.mysql.lists.javaRe: Getting foreign keys.| From | Sent On | Attachments |
|---|---|---|
| Mofeed Shahin | 11 Dec 2003 22:44 | |
| Jeff Newmiller | 12 Dec 2003 10:20 | |
| Chris McGowan | 12 Dec 2003 10:38 | |
| Mark Matthews | 12 Dec 2003 10:55 | |
| Chris McGowan | 12 Dec 2003 11:52 | |
| Mofeed Shahin | 14 Dec 2003 15:08 | |
| Christian Mack | 17 Dec 2003 10:02 | |
| Mofeed Shahin | 17 Dec 2003 14:31 | |
| Susidzaimah Pg Sulaiman | 30 Jan 2004 00:38 | |
| Scott Queen | 30 Jan 2004 06:43 | |
| Mike Markovich | 30 Jan 2004 07:12 | |
| Susidzaimah Pg Sulaiman | 31 Jan 2004 17:26 | |
| Susidzaimah Pg Sulaiman | 31 Jan 2004 17:27 | |
| Scott Queen | 31 Jan 2004 19:07 | |
| Keith Hatton | 02 Feb 2004 01:26 | |
| Mike Markovich | 02 Feb 2004 07:49 | |
| Susidzaimah Pg Sulaiman | 02 Feb 2004 23:40 | |
| Susidzaimah Pg Sulaiman | 03 Feb 2004 19:01 |
| Subject: | Re: Getting foreign keys.![]() |
|---|---|
| From: | Chris McGowan (Chri...@Colorado.edu) |
| Date: | 12/12/2003 10:38:57 AM |
| List: | com.mysql.lists.java |
Mofeed,
Jeff's correct. You'll need to use InnoDB tables for foreign keys to work. But it seems useless to use foreign keys unless you're using Constraints. Just add type=InnoDB to the end of your create table() syntax and it should work:
CREATE TABLE Student (Stud_ID INT) TYPE=innodb;
I messed around with your problem and couldn't get J/Connector to show anything for Foreign Keys. But then again, I'm unaware of any MySQL query/function that actually shows foreign key information, except for: SHOW CREATE TABLE table_name;
It may be a lost cause :(
-Chris McGowan Project Manager / Software Developer School of Law Registrar's Office University of Colorado at Boulder 401 UCB Boulder, CO 80309 (303) 931-1599
----- Original Message ----- From: "Jeff Newmiller" <jdne...@dcn.davis.ca.us> To: "Mofeed Shahin" <mofe...@dsto.defence.gov.au> Cc: <ja...@lists.mysql.com> Sent: Friday, December 12, 2003 11:20 AM Subject: Re: Getting foreign keys.
On Fri, 12 Dec 2003, Mofeed Shahin wrote:
Hey guys,
I've just started to play with MySQL, and am trying to get something I wrote to talk to it, but I'm having problems getting foreign key information out of the database.
[...]
The Tables are created like so :
CREATE TABLE Student ( Student_ID INT PRIMARY KEY, First_Name varchar(50), Last_Name varchar(50), UNIQUE (First_Name, Last_Name) );
CREATE TABLE Address ( First_Name varchar(50), Last_Name varchar(50), Address varchar(50), PRIMARY KEY (First_Name, Last_Name), FOREIGN KEY (First_Name, Last_Name) REFERENCES student (First_Name, Last_Name) );
The problem is that when I do meta.getImportedKeys(...), it returns an empty set. I've tried the same thing, but using a single column foreign key, but that still returns an empty set.....
MySQL tables don't support foreign keys... the syntax just gets swallowed.
Try InnoDB tables... RTF-MySQL-M. I don't know if Connector/J will dig up the information you want, but until foreign keys are actually present you can't expect to get information on them.
-------------------------------------------------------------------------- - Jeff Newmiller The ..... ..... Go Live... DCN:<jdne...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...2k
-------------------------------------------------------------------------- -
-- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe: http://lists.mysql.com/java?unsub=chri...@colorado.edu




