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: "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:
Verify that the table employee2 is no more in the database.
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.