All Forums Database
teradatakash 6 posts Joined 12/11
22 Jan 2012
Alter Table column defined as foreign key

Hello, 

I have two tables. Employee & department.

employee[emp_id, emp_name, Department_id, emp_address]

department[department_id, department_name]

Department_id in employee table has been defined as a foreign key on Department.department_id
and Null values are allowed.

I am trying to alter employee table to alter department_id NOT NULL using below query. 
ALTER TABLE Employee
Add Department_ID NOT NULL INTEGER

I am getting an error that "Foreign key column Department_ID can not be modified."

Can I  not  modify foreign key column in referncing table? If Yes how?

 

Stefans 38 posts Joined 02/12
13 Mar 2012

Just a thought..

Drop the foreign key reference and then try to alter the table.....

Stalin

Stefans 38 posts Joined 02/12
13 Mar 2012

Also,the column type that you are trying to change to NOT NULL if it is indexed then the attributes can not be altered.For non-indexed column defined as NULL can be altered to NOT NULL provided that the column does not contain nulls.

Stalin

You must sign in to leave a comment.