how to alter a table and add foreign key to it

Posted by Shanky11 under Others on 8/28/2012 | Points: 10 | Views : 881 | Status : [Member] | Replies : 6
ALTER TABLE score ADD CONSTRAINT fk_sco
FOREIGN KEY (sid)
REFERENCES student (sid);


tabel name=score i want to alter score and add foreign key to it reference to student table




Responses

Posted by: Atal.Upadhyay on: 8/28/2012 [Member] Starter | Points: 25

Up
0
Down
You may use following :

ALTER TABLE score
ADD CONSTRAINT score_student FOREIGN KEY (sid)
REFERENCES student (sid);


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

ALTER TABLE score ADD constraint fk_sco FOREIGN KEY(sid) REFERENCES student (sid)


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Maheshvishnu on: 9/6/2012 [Member] Starter | Points: 25

Up
0
Down
Your query is correct.

r u getting any error

mahesh

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Shanky11,
Please Mark as Answer if it helpful to you..That helps others who search the same...

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Shanky11,
Alter Table Score Add Constraint Fk_Sco Foreign Key(sid) References student(sid);

Thanks & Regards
Hari

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Shanky11,
Please Mark as Answer if u satisfied for this answer

Thanks & Regards
Hari

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response