Files
integral-shop/docs/com-xsj33-data-imgration.md
danaisuiyuan fd4255d982 docs(xsj33): 迁移说明移入 docs/
与其他迁移文档(byjyw149/czrt6/sxsy80 等)同位,便于统一索引

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-16 18:31:26 +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`
## 相关文件