MySQL Drop Table

The DROP TABLE command is used to delete or drop a table.

Let's drop a table named employee2.

Create a js file named "delete" in DBexample folder and put the following data into it:

var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "12345",
database: "rookienerd"
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");

Now open command terminal and run the following command:

Node drop.js
Node.js drop table 1

Verify that the table employee2 is no more in the database.

Node.js drop table 2
Related Tutorial
Follow Us #
Contents +