Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How to Drop a foreign key constraint which was created along with the table creation??

2 posters

Go down

How to Drop a foreign key constraint which was created along with the table creation?? Empty How to Drop a foreign key constraint which was created along with the table creation??

Post by Christopher Thu Mar 25, 2010 1:18 pm

I have created a table with a foreign key. tat is i created the foreign key in the "CREATE TABLE" stmt itself. how to drop this foreign key.??
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

How to Drop a foreign key constraint which was created along with the table creation?? Empty Re: How to Drop a foreign key constraint which was created along with the table creation??

Post by abhisheksingh Thu Mar 25, 2010 1:39 pm

alter table table_name drop constraint FK_constraint_name;
abhisheksingh
abhisheksingh

Posts : 10
Points : 117
Join date : 2010-03-09
Age : 37
Location : Haldia

Back to top Go down

How to Drop a foreign key constraint which was created along with the table creation?? Empty Re: How to Drop a foreign key constraint which was created along with the table creation??

Post by abhisheksingh Thu Mar 25, 2010 1:46 pm

and if u dnt know the foreign key name then just insert any row that will violate the constraint then u will get error from
system stating
cannot validate (SCOTT.FK_DEPTID) - parent keys not found

here fk_deptid is the foreign key
n then u can use the said command.
abhisheksingh
abhisheksingh

Posts : 10
Points : 117
Join date : 2010-03-09
Age : 37
Location : Haldia

Back to top Go down

How to Drop a foreign key constraint which was created along with the table creation?? Empty Re: How to Drop a foreign key constraint which was created along with the table creation??

Post by Christopher Thu Mar 25, 2010 3:31 pm

abhisheksingh wrote:and if u dnt know the foreign key name then just insert any row that will violate the constraint then u will get error from
system stating
cannot validate (SCOTT.FK_DEPTID) - parent keys not found

here fk_deptid is the foreign key
n then u can use the said command.
yes.. it works. thx.
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

How to Drop a foreign key constraint which was created along with the table creation?? Empty Re: How to Drop a foreign key constraint which was created along with the table creation??

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum