0

Assume we have four tables

employee, employee_history, employee_details, emp_details_history

employee_history is a duplicate of employee emp_details_history should be the duplicate of employee_details

Instead of referring employee_history in emp_details_history people have referred employee table and created column and has values as well.

Now i want to change the foreign key column name of employee_details_history to point to employee_history instead of emp_details.

employee_details_history has COLUMNS pkey AND employee_id (instead of pkey AND employee_history_id)

the system is not allowing to delete the employee record as it is referred in the history table. history is different and actual record should be different.

Now would like to point to the correct column and name.

could you please help me how to change the foreign key column and name?

Thanks in advance.

Kathiresa
  • 75
  • 7

1 Answers1

0
         1. To remove foreign key constraints
            go to phpmyadmin

            select prefered table

            select structure

            click relational view link under the structure

            change the Foreign key constraint of needed columns


         2. to change column names

            go to phpmyadmin

            select prefered table

            select structure
            click change link of preferred column
            change the column name

if you want as a query to change column name try this Error renaming a column in MySQL

if you want to delete foreign key try this MySQL Removing Some Foreign keys

Hope this helps

Community
  • 1
  • 1
safin chacko
  • 1,345
  • 1
  • 11
  • 18