In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you how to write a command to delete a table in sql language, I believe most people still don't know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go and find out!
SQL language, delete a table command is "DROP", the specific syntax format "DROP TABLE [IF EXISTS] table name". The DROP TABLE command can delete multiple tables at the same time by writing the table names sequentially, separated from each other by commas.
In SQL, the command to delete a table is ( ).
A.DELETE
B.DROP
C.CLEAR
D.REMOVE
Answer: B.DROP
answer analysis
SQL language, the establishment of a table command is CREATE, table modification command is ALTER, delete a table command is DROP, in addition to the table data insertion, delete, query commands are INSERT, UPDATE and SELECT.
Additional information:
In MySQL databases, tables that are no longer needed can be deleted from the database.
At the same time as deleting the table, the structure of the table and all the data in the table will be deleted, so it is best to backup before deleting the data table, so as not to cause irreparable damage.
Use the DROP TABLE statement to delete one or more data tables, with the following syntax:
DROP TABLE [IF EXISTS] table name
A description of the syntax format is as follows:
Table Name: Indicates 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 in sequence and separated from each other by commas.
IF EXISTS is used to determine whether a data table exists before deleting it. If IF EXISTS is not added, MySQL will prompt an error when the data table does not exist and interrupt the execution of the SQL statement; if IF EXISTS is added, the SQL statement can be executed smoothly when the data table does not exist, but a warning will be issued.
Two caveats:
The user must have permission to execute the DROP TABLE command, otherwise the data table will not be deleted.
When a table is deleted, user permissions on the table are not automatically deleted.
Examples:
mysql> SHOW TABLES;+--------------------+| Tables_in_test_db |+--------------------+| tb_emp2 || tb_emp3 |+--------------------+2 rows in set (0.00 sec)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)
The execution result shows that the table named tb_emp3 no longer exists in the data table list of test_db database, and the deletion operation is successful.
Above is sql language delete a table command how to write all the content, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to 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.