In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the method of deleting the data table by mysql, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
In mysql, you can use "DROP TABLE" to delete one or more data tables, the syntax format "DROP TABLE [IF EXISTS] table name 1 [, table name 2, table name 3.];"; when the table is deleted, the structure of the table and all data in the table will be deleted.
In the MySQL database, we can delete tables from the database that are no longer needed.
When deleting the table, the structure of the table and all the data in the table will be deleted, so it is best to back up the data table before deleting it, so as to avoid irreparable losses.
The method of deleting data Table in MySQL Database
Use the DROP TABLE statement to delete one or more data tables in the following syntax format:
DROP TABLE [IF EXISTS] Table name 1 [, Table name 2, Table name 3.]
The syntax format is described as follows:
Table name 1, table name 2, table name 3. Represents the name of the data table to be deleted. DROP TABLE can delete multiple tables at the same time, as long as the table names are written after each other and separated by commas.
IF EXISTS is used to determine whether a data table exists before it is deleted. Without IF EXISTS, MySQL will prompt an error when the data table does not exist and interrupt the execution of the SQL statement; with IF EXISTS, the SQL statement can be executed smoothly when the data table does not exist, but will issue a warning (warning).
Two points to note:
The user must have permission to execute the DROP TABLE command, or the data table will not be deleted.
When a table is deleted, the user's permissions on the table are not automatically deleted.
Example:
Query the data table of test_db database
Mysql > USE test_db;Database changedmysql > SHOW TABLES;+-+ | Tables_in_test_db | +-+ | tb_emp2 | | tb_emp3 | +-+ 2 rows in set (0.00 sec)
From the running results, we can see that there are two data tables, tb_emp2 and tb_emp3, in test_tb database.
Let's delete the data table tb_emp3. The SQL statement entered and the run result are as follows:
Mysql > DROP TABLE tb_emp3;Query OK, 0 rows affected (0.22 sec) mysql > SHOW TABLES;+-+ | Tables_in_test_db | +-+ | tb_emp2 | +-+ 1 rows in set (0.00 sec)
As can be seen from the execution result, the table named tb_emp3 no longer exists in the datasheet list of the test_db database, and the delete operation was successful.
The above are all the contents of the method of deleting the data table by mysql. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.