Node.js MySQL Drop Table

Node.js MySQL Drop 

MySQL package is used to Drop table from database

DROP TABLE mysql statement is used to drop table in mysql database.

Example : 

const mysql = require('mysql');

const db = mysql.createConnection({

     host: "localhost",
     user: "root",
     password: "*******",
     database : "aryadb"


// connect to database

db.connect((err) => {

    if (err) {

        throw err;


     console.log('Connected to database!');

     db.query("drop table employee ", function (err, result) {
          if (err) throw err;
               console.log("employee table is deleted!");


Write above code in server.js file and run this program as below.

D:\nodejs\website> node server.js  

It gives output as below.

employee table is deleted!


Leave a Reply

Your email address will not be published. Required fields are marked *