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

Go down

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

Post by Christopher on 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.??
avatar
Christopher
Admin

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

View user profile http://unixcpp.forumotion.com

Back to top Go down

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

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

alter table table_name drop constraint FK_constraint_name;
avatar
abhisheksingh

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

View user profile

Back to top Go down

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

Post by abhisheksingh on 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.
avatar
abhisheksingh

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

View user profile

Back to top Go down

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

Post by Christopher on 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.
avatar
Christopher
Admin

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

View user profile http://unixcpp.forumotion.com

Back to top Go down

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