You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
641 B

const pool = require('../db');
async function deleteTable(req, res) {
const { tableName } = req.body; // 从请求体中获取表名
let connection;
try {
connection = await pool.getConnection();
await connection.query(`DROP TABLE IF EXISTS ??`, [tableName]); // 删除表
connection.release();
res.json({ message: `成功删除` });
} catch (error) {
console.error('删除表失败:', error);
res.status(500).json({ error: '删除表失败' });
} finally {
if (connection) {
connection.release();
}
}
}
module.exports = { deleteTable };