Files
integral-shop/com-xsj33-data-imgration.md
apple e7ffbbf302 docs(sxsy80): 补充文档、合同资源与数据清理脚本
- 更新前后端 sign_contract_sxsy80.pdf
- 增加 com-sxsy80 说明、数据迁移与 SQL/执行脚本
- 增加 com-xsj33 数据迁移说明与 docs 下合同源文件

Made-with: Cursor
2026-04-26 16:50:36 +08:00

56 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 公司名称:夏盛军商贸
## mysql数据库配置信息
host ip: 39.106.63.33
datasource:
name: yangtangyoupin
username: yangtangyoupin
password: 5Fn8eWrbYFtAhCZw
## 数据删除任务
- 用户数据范围暨**用户id集**wa_users表中的用户id集
- 查询wa_withdraw表中用户id不在用户数据范围内的记录并写一个删除这些数据的sql
### 1) 查询核对 SQL
```sql
-- 统计孤立提现记录数
SELECT COUNT(*) AS orphan_cnt
FROM wa_withdraw w
WHERE NOT EXISTS (
SELECT 1 FROM wa_users u WHERE u.id = w.user_id
);
-- 抽样查看前 100 条,核对是否确实需要清理
SELECT w.*
FROM wa_withdraw w
WHERE NOT EXISTS (
SELECT 1 FROM wa_users u WHERE u.id = w.user_id
)
ORDER BY w.id
LIMIT 100;
```
### 2) 删除 SQL
```sql
DELETE w FROM wa_withdraw w
WHERE NOT EXISTS (
SELECT 1 FROM wa_users u WHERE u.id = w.user_id
);
```
### 3) 操作备注
- 建议在执行前对 wa_withdraw 做一次备份:`CREATE TABLE wa_withdraw_bak_20260423 AS SELECT * FROM wa_withdraw;`
- 建议先跑 `COUNT(*)``LIMIT 100` 人工核对,再执行 `DELETE`
- 全程放入事务中执行,确认无误后再 `COMMIT`
## 相关文件