-
新增字段
ALTER TABLE DWD_ZL_CZLR_RY ADD MOIDD BIGINT;
-
删除字段
ALTER TABLE DWD_ZL_CZLR_RY DROP COLUMN MOIDD;
- 填充随机唯一值
UPDATE DWD_ZL_CZLR_RY A SET moidd = (
SELECT rowid FROM DWD_ZL_CZLR_RY B WHERE A.rowid = B.rowid
);
- 去重保留最小ID值
DELETE FROM DWD_ZL_CZLR_RY WHERE zjhm IN (
SELECT zjhm FROM DWD_ZL_CZLR_RY GROUP BY zjhm HAVING COUNT(*) > 1
) AND moid NOT IN (
SELECT MIN(moidd) FROM DWD_ZL_CZLR_RY GROUP BY zjhm HAVING COUNT(*) > 1
);