In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you mysql batch delete multiple tables of the method, I believe that most people do not understand, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Mysql batch delete multiple table method: use the "DROP TABLE" statement, as long as the table names are written after each other, separated by commas; syntax format "DROP TABLE [IF EXISTS] table name 1 [, table name 2, table name 3.]".
Mysql deletes multiple tables in batch
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 in the database
Mysql > SHOW TABLES;+-+ | Tables_in_test_db | +-+ | tb_emp1 | | tb_emp2 | | tb_emp3 | +-+ 2 rows in set (0.00 sec)
From the running results, we can see that there are three data tables of tb_emp1, tb_emp2 and tb_emp3 in the database.
Let's delete the data tables tb_emp1 and tb_emp3. The SQL statement entered and the run result are as follows:
Mysql > DROP TABLE tb_emp1,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 tables named tb_emp1 and tb_emp3 no longer exist in the datasheet list of the test_db database, and the delete operation was successful.
The above are all the contents of mysql's method of deleting multiple tables in batches. Thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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.