MySQL Drop Table

MySQL DROP TABLE Statement


The DROP TABLE statement in MySQL is used to permanently delete a table from a database, along with all its data, indexes, and structure. This action CANNOT be undone, so use it with caution.


Syntax:


DROP TABLE table_name;


  • table_name is the name of the table you want to delete.
Example: Deleting a Table
DROP TABLE students;
  • This command removes the students table and all its data from the database.

Drop Multiple Tables at Once


You can delete multiple tables in one command:




Example: Deleting multiple Table
DROP TABLE students, courses, teachers;

Alternative: Use TRUNCATE Instead of DROP


If you want to delete all rows but keep the table structure, use:

Example
TRUNCATE TABLE students;
  • This removes all data but keeps the table structure intact.

Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.