'use strict'; /** * 抽查 UPDATE 影响范围。 * * @return {Promise} */ const mysql = require('mysql2/promise'); async function main() { const connection = await mysql.createConnection({ host: '127.0.0.1', port: 3307, user: 'wms', password: 'dspxmRwRdRbWtbm7', database: 'wms', }); try { const [ sample ] = await connection.query( `SELECT id, create_at FROM wms_order_delivery_100000 WHERE id BETWEEN 1591 AND 1660 ORDER BY id ASC LIMIT 15` ); console.log('===== 1591-1660 区间 ====='); console.log(JSON.stringify(sample)); const [ todayCount ] = await connection.query( `SELECT COUNT(1) AS cnt FROM wms_order_delivery_100000 WHERE create_at >= '2026-09-05 16:00:00'` ); console.log('===== 全表今天订单数 ====='); console.log(JSON.stringify(todayCount)); const [ keepRows ] = await connection.query( `SELECT id, create_at FROM wms_order_delivery_100000 WHERE id IN (1245, 3014, 5547, 6327, 6462, 7797, 7909, 8455) ORDER BY id ASC` ); console.log('===== 保留8条 ====='); console.log(JSON.stringify(keepRows)); } finally { await connection.end(); } } main().catch(error => { console.error(`查询失败: ${error.message}`); process.exit(1); });