SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES'; DROP TABLE IF EXISTS coordT ; CREATE TABLE IF NOT EXISTS coordT ( nodeId INT UNSIGNED NOT NULL, latitude DECIMAL(12,7) NOT NULL, longitude DECIMAL(12,7) NOT NULL, PRIMARY KEY (nodeId), CONSTRAINT fk_coordT_nodeT1 FOREIGN KEY (nodeId) REFERENCES nodeT (id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; insert coordT(nodeId, latitude, longitude) select o.id, o.latitude, o.longitude from objectT o where o.latitude is not null and o.longitude is not null; alter table objectT drop latitude; alter table objectT drop longitude;