In the sql language, the command to delete a table is “DROP”, and the specific syntax format is “DROP TABLE [IF EXISTS] table name”. The “DROP TABLE” command can delete multiple tables at the same time, as long as the table names are written one after the other, separated by commas.
(Recommended tutorial: mysql video tutorial)
In the SQL language, the command to delete a table is ( ).
A. DELETE
B. DROP
C. CLEAR
D. REMOVE
Answer:B. DROP
Answer analysis
In the SQL language, the command to create a table is CREATE, the command to modify the table is ALTER, delete The command for a table is DROP, and the inserting, deleting and querying commands for data in the table are INSERT, UPDATE and SELECT respectively.
Extended information:
In the MySQL database, for data tables that are no longer needed, we can delete them from the database.
While 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 table before deleting the data table to avoid irreparable losses.
Use the DROP TABLE
statement to delete one or more data tables, the syntax is as follows:
DROP TABLE [IF EXISTS] table name
The description of the grammar 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 one after the other, separated by commas. -
IF EXISTS
is used to determine whether the table exists before deleting the data table. If IF EXISTS is not added, MySQL will prompt an error and interrupt the execution of the SQL statement when the data table does not exist; after adding IF EXISTS, the SQL statement can be executed smoothly when the data table does not exist, but a warning (warning) will be issued.
Two points to note:
-
The user must have the ability to execute DROP TABLE Command permission, otherwise the data table will not be deleted.
-
When a table is deleted, the user’s permissions on the table are not automatically deleted.
Example:
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)
As you can see from the execution results, the table named tb_emp3 does not exist in the data table list of the test_db database, and the deletion operation is successful.
For more knowledge about programming, please visit: Programming Courses! !
The above is the SQL language, what is the command to delete a table? For more details, please pay attention to other related articles on 1024programmer.com!