Node.js MySQL删除表

DROP TABLE命令用于删除或删除表。

让我们删除一个名为employee2的表。

在DBexample文件夹中创建一个名为” delete”的js文件, 并将以下数据放入其中:

var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost", user: "root", password: "12345", database: "srcmini"
});
con.connect(function(err) {
if (err) throw err;
var sql = "DROP TABLE employee2";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Table deleted");
});
});

现在打开命令终端并运行以下命令:

Node drop.js
Node.js删除表1

验证表employee2是否不再存在于数据库中。

Node.js删除表2

来源:

https://www.srcmini02.com/27914.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_38367.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?