Home >Database >Mysql Tutorial >How to delete table in mysql
In mysql, you can use the "DORP TABLE" statement to delete a data table. The general syntax format is "DROP TABLE table_name;"; among them, "table_name" represents the name of the data table to be deleted, and you can specify multiple data table names, as long as they are separated by commas.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Deleting a data table in MySQL is very easy, but you must be very careful when deleting a table, because all data will disappear after executing the delete command.
The following is the general syntax for deleting a MySQL data table:
DROP TABLE table_name ;
table_name
: Indicates the name of the data table to be deleted. DROP TABLE can delete multiple tables at the same time. Just write the table names at the end and separate them with commas.
Example:
First check the data table in the test_db database
mysql> USE test_db; Database changed mysql> SHOW TABLES; +--------------------+ | Tables_in_test_db | +--------------------+ | tb_emp1 | | tb_emp2 | | tb_emp3 | +--------------------+ 3 rows in set (0.00 sec)
If you want to delete the data table tb_emp2
mysql> DROP TABLE tb_emp2; Query OK, 0 rows affected (0.22 sec) mysql> SHOW TABLES; +--------------------+ | Tables_in_test_db | +--------------------+ | tb_emp1 | | tb_emp3 | +--------------------+ 2 rows in set (0.00 sec)
As you can see from the execution results, the table named tb_emp2 no longer exists in the data table list of the test_db database, and the deletion operation was successful.
Related free learning recommendations: mysql video tutorial
The above is the detailed content of How to delete table in mysql. For more information, please follow other related articles on the PHP Chinese website!