How to Remove Foreign Key Constraint
619418Jan 24 2008 — edited Jun 6 2008Hello Freinds,
I have created two sample tables ...
----------------------------------------------------------------
create table primaryTable(id int primary key,value int);
OK; 1 row affected
create table childTable(id1 int primary key,id int references primaryTable(id),value int);
OK; 1 row affected
ants_dsn_3.4> select * from childTable;
---------------------------------------
| ID1 | ID | VALUE |
---------------------------------------
| 1 | 1 | 1 |
| 2 | 2 | 1 |
| 3 | 3 | 1 |
---------------------------------------
OK; Returned 3 rows from 3 fields
ants_dsn_3.4> select * from primaryTable;
--------------------------+
| ID | VALUE |
--------------------------+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
--------------------------+
I want to drop the Foreign key in the Child Table.
And when i do that i get the Following error.
ants_dsn_3.4> alter table childTable drop ID;
[ANTs Software][ANTs DATABASE ODBC driver][ants_dsn_3.4] Server returned error : ERROR (70007): Cannot drop the column 'ID' that has a constraint on it
----------------------------------------------------------------
Freinds Can you help to solve this problem as iam new to data base side.
Thanks in advance,
Faizan.