Home > Database > Mysql Tutorial > How to delete mysql table

How to delete mysql table

PHPz
Release: 2023-04-19 15:12:37
Original
13638 people have browsed it

MySQL is a commonly used relational database management system. If you need to delete a MySQL table, you may be a little confused. This article will introduce you how to delete a MySQL table.

There are two ways to delete a MySQL table, one is to use the MySQL command line tool, and the other is to use the MySQL Workbench UI tool.

Here, we will introduce these two methods respectively.

Method 1: Use the MySQL command line tool to delete the table

  1. First, enter the MySQL command line tool. You can use the following command in the terminal or command prompt:
mysql -u [username] -p
Copy after login

Among them, username represents your user name in MySQL. After executing this command, the system will ask you to enter your password.

  1. Enter the password and press Enter to enter the MySQL system. After knowing the password, type:
use [database_name];
Copy after login

where database_name is the name of the database where the table you want to delete is located.

  1. Then, enter the following command:
DROP TABLE [table_name];
Copy after login

Among them, table_name is the name of the table you need to delete. After executing this command, MySQL will delete this table from the database.

  1. Finally, exit the MySQL system. Enter the following command:
exit
Copy after login

Now, you have successfully deleted the MySQL table.

Method 2: Use MySQL Workbench UI to delete tables

If you don’t want to use the command line, MySQL Workbench UI provides a more intuitive method.

  1. Open MySQL Workbench. In the left panel of the main interface, select the database where the table you want to delete is located.
  2. In the left panel, expand the "Tables" folder under the database. Find the table you want to delete.
  3. Select the table, right-click and select "Drop Table".
  4. In the pop-up box, click "OK". MySQL Workbench will prompt you that the deleted table will not be recoverable.
  5. Finally, click the “Apply” button.

Now, you have successfully deleted the MySQL table.

Summary

Deleting a MySQL table is very simple whether using the MySQL command line tool or the MySQL Workbench UI. If you no longer need the table, you can easily delete it by following these simple steps in MySQL.

The above is the detailed content of How to delete mysql table. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template