VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-mysql-drop-table/

⇱ Node.js MySQL Drop Table - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js MySQL Drop Table

Last Updated : 7 Oct, 2021

DROP TABLE Query is used to Delete or Drop a table from MySQL Database.

Syntax:

  • This will delete users table. But this will throw error if users table is not there.
    DROP TABLE users
  • This will delete users table only if it exist.
    DROP TABLE IF EXISTS users
    • Modules:

      • mysql: To handle MySQL connection and Queries
        npm install mysql

      SQL gfg_db Database Preview (showing tables):

      👁 Image

      Example 1: Delete users Table

      Output:

      👁 Image

      Example 2: Delete users Table only if it Exists

      Output:

      👁 Image
      👁 Image
    Comment

    Explore