Node JS - Node js MySQL Drop Table - Node - Node JS tutorial - webnode
Related nodejs article tags - node js - node js tutorial - node js examples
Drop a Table
- You can delete or drop an existing table by using the "DROP TABLE" statement in mysql.

Learn Node js - node js Tutorial - node-js mysql drop table - node - Node js Examples
Example
Delete the table "wikitechy_customers":
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "yourusername",
password: "yourpassword",
database: "mydb"
});
con.connect(function(err) {
if (err) throw err;
var sql = "DROP TABLE customers";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Table deleted");
});
});
- Save the code above in a file called "wikitechy_db_drop_table.js" and run the Node JS Tutorial File:
Run "wikitechy_db_drop_table.js"
C:\Users\Your Name>node wikitechy_db_drop_table.js
Related nodejs article tags - node js - node js tutorial - node js examples
Node JS Output :
- You can delete or drop an existing table by using the "DROP TABLE" statement in mysql.
Table deleted