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:

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

snippet
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
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents