Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1956

REFERENCES table is changed when rename the parent table (no replies)

$
0
0
Hi

i am working on 5.5.37 mysql and AWS RDS instance

i have two tables
objects (parent table have more 5 million rows) and object_units( child table have more than 8 million rows)
there is forgein key between them

CONSTRAINT `fk_object_units_1` FOREIGN KEY (`id_object`) REFERENCES `objects` (`id_object`),

and i am trying to modify the parent table to modify column and add new column ,
to avoid "Waiting for table metadata lock" thread status that happend when run alter statement ,
i create new table, it's structure have the changes that i need named by objects_new ,
and i copy the data from table objects to table objects_new , and that working fine with me .

in the last step i did the following rename command:
rename table objects to objects_old ,objects_new to objects ;

then implicitly the reference on child table become objects_old as the following:

CONSTRAINT `fk_object_units_1` FOREIGN KEY (`id_object`) REFERENCES `objects_old` (`id_object`),
so new table " objects" is not more the perant of child , the parent is objects_old , so my "work arround" is failed


my question is
i need step of process to do my modifications on parent table without locking the table and minimum side-effects on DB load and performance ?

Viewing all articles
Browse latest Browse all 1956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>