LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-12-2004, 04:31 PM   #1
munna_502
LQ Newbie
 
Registered: Aug 2003
Location: Pakistan
Posts: 29

Rep: Reputation: 15
Mysql Foreign Key


Hi readers,
I am new in mysql but i have all the conceptes of SQL.I am create the relation of primary key and foreign key in tables.The join is working but when i will delete a parent record it delete the parent record.
my requirement is it will give me the error like oracle ,when we have child record then we can not delete the parent records.and also when insertin data in child it inserted the date whetever the parent is exist or not.
My sql statments are

for parent tables

CREATE TABLE student(stu_id int(10)PRIMARY KEY,
stu_name VARCHAR(20) NOT NULL,
email varchar(30));
for child table

CREATE TABLE course (course_id int PRIMARY KEY,
course_name varchar(30)NOT NULL,
stu_id int(10),
FOREIGN KEY(stu_id)
REFERENCES student(stu_id));

Please help me urgent
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
Bad Key / No Key Error MySql wasabi Linux - Software 1 04-19-2005 06:06 PM
Foreign languages floppywhopper LQ Suggestions & Feedback 24 01-07-2005 06:48 AM
MySQL Primairy Key problem agallant Programming 6 06-27-2004 11:12 PM
Foreign Charachters geekzen Linux - General 0 04-16-2004 04:26 PM


All times are GMT -5. The time now is 05:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration