Home  >  Article  >  Database  >  Delete operation of table in MySql

Delete operation of table in MySql

黄舟
黄舟Original
2017-08-09 15:25:581295browse

In MySql, there are two ways to delete a table:

(1) drop table table_name, which is the most commonly used method, directly delete the table to be deleted;

(2) drop database database_name, that is, delete the database where the table is located.

Delete operation of table in MySql

1. Preparation: (1) Open the mysql console; log in with the root account; display all databases; show databases.

Delete operation of table in MySql

Delete operation of table in MySql


#2. Preparation: (2) Select the database named test, use test; and then view the tables in the test database, use the show tables; command.

Delete operation of table in MySql


##3. First method: Delete quiz table, drop table quiz; check the table in test again and find that there is no quiz table.

Delete operation of table in MySql


##4. The second method: ( 1) Type in source "absolute path/quiz.sql", re-import the quiz table into the test database, then use show tables; check the tables in the database, there is a quiz table.

Delete operation of table in MySql

Delete operation of table in MySql


#5. The second method: (2) Use drop database test; at this time, the entire test database is deleted. For further confirmation, you can use the show databases; command to check that the database obtained does not have a test database.

Delete operation of table in MySql

##Note

The command must end with;

Do not delete databases and tables casually to avoid losing important data

##

The above is the detailed content of Delete operation of table in MySql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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