Try creating your tables as such:
CREATE TABLE test1(ser INT(5) NOT NULL, 
age INT(2), 
PRIMARY KEY (ser) ) 
TYPE=InnoDB;

CREATE TABLE test1(serno INT(5) NOT NULL, 
name VARCHAR(20), 
KEY 'idx_serno' (serno), 
CONSTRAINT FOREIGN KEY(serno) REFERENCES `test1` (ser) )
TYPE=InnoDB;


-----Original Message-----
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: 4/16/04 12:26 PM
Subject: Re: Foreign Key

I creates 2 tables

create table test1(Ser int(5) primary key,age int(2)) type=InnoDB;

create table test2(Serno int(5) references test1(Ser),name varchar(20)) 
type=InnoDB;

I inserted a value in test2 and it accepted. Isnt that wrong? shouldnt
it 
accept only if there is a vlue in the first table? I didnt enter any
records 
in the first table.

Liza

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to