Mysql
 sql >> Database >  >> RDS >> Mysql

Sincronizzazione della chiave primaria tra due tabelle archiviate in due database diversi

Puoi farlo

CREATE TABLE TableA_TMP AS
SELECT * FROM TableA;

ALTER TABLE TableA_TMP ADD id_new int;

UPDATE TableA_TMP A INNER JOIN TableB B ON lower(A.title) = lower(B.title)
SET id_new = B.id;

RENAME TABLE TableA TO TableA_backup;    

CREATE TableA AS
select id_new as id, title,.... from TableA_TMP;