去除数据库冗余记录
BEGIN
DECLARE tableName VARCHAR(50);
SET tableName=tblName;
IF tableName='ppm.ppm_project' THEN
DROP TABLE IF EXISTS ppm.ppm_project;
CREATE TABLE ppm.ppm_project SELECT * FROM ppm.ppm_project_ti;
ALTER TABLE ppm.ppm_project ADD PPM_INCREMENT BIGINT AUTO_INCREMENT UNIQUE;
DELETE FROM ppm.ppm_project WHERE PPM_INCREMENT NOT IN (SELECT * FROM
( SELECT MAX(PPM_INCREMENT) FROM ppm.ppm_project GROUP BY UPROJECTID) o );
ALTER TABLE ppm.ppm_project DROP COLUMN PPM_INCREMENT;
ALTER TABLE ppm.ppm_project CHANGE UPROJECTID UPROJECTID varchar(100) NOT NULL PRIMARY KEY;
END IF;