How to delete a MySQL table

How to delete a MySQL table

It is very easy to delete a table in MySQL, but you must be very careful when doing so, because all data will disappear after the deletion command is executed.

grammar

The following is the general syntax for deleting a MySQL table:

DROP TABLE table_name ;

Deleting a table in the command prompt window

In the mysql> command prompt window, the SQL statement to delete the data table is DROP TABLE

Method extension:

There are two ways to delete data in MySQL, one is the DELETE statement and the other is the TRUNCATE TABLE statement. The DELETE statement can select the records to be deleted through WHERE. Using TRUNCATE TABLE will delete all records in the table. Therefore, the DELETE statement is more flexible.
If you want to clear all records in a table, you can use the following two methods:

  1. DELETE FROM table1
  2. TRUNCATE TABLE table1

The TABLE in the second record is optional.

If you want to delete some records in a table, you can only use the DELETE statement.

DELETE FROM table1 WHERE ...;

This is the end of this article about how to delete MySQL data tables. For more information about simple methods to delete MySQL data tables, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • MySQL data table partitioning strategy and advantages and disadvantages analysis
  • Basic operations of MySQL data tables: table structure operations, field operation example analysis
  • A simple method to merge and remove duplicate MySQL tables
  • Detailed basic operations on data tables in MySQL database

<<:  4 ways to view processes in LINUX (summary)

>>:  Detailed explanation of keepAlive use cases in Vue

Recommend

Storage engine and log description based on MySQL (comprehensive explanation)

1.1 Introduction to storage engines 1.1.1 File sy...

Mysql join query syntax and examples

Connection query: It is the result of connecting ...

Detailed steps for installing and using vmware esxi6.5

Table of contents Introduction Architecture Advan...

Use of Linux relative and absolute paths

01. Overview Absolute paths and relative paths ar...

How to write asynchronous tasks in modern JavaScript

Preface In this article, we'll explore the ev...

The difference between hash mode and history mode in vue-router

vue-router has two modes hash mode History mode 1...

Detailed explanation of the usage and function of MySQL cursor

[Usage and function of mysql cursor] example: The...

Detailed explanation of Bootstrap grid vertical and horizontal alignment

Table of contents 1. Bootstrap Grid Layout 2. Ver...

MySQL 8.0.21 installation steps and problem solutions

Download the official website First go to the off...

React Hook usage examples (6 common hooks)

1. useState: Let functional components have state...

Implementation steps for docker-compose to deploy etcd cluster

Table of contents Write docker-compose.yml Run do...

MySQL extracts Json internal fields and dumps them as numbers

Table of contents background Problem Analysis 1. ...