4.2.11. MySQL delete data table

发布时间 :2025-10-25 12:31:19 UTC      

Deleting tables in MySQL is very easy to operate, but you have to be very careful when deleting tables, because all data will disappear after executing the delete command.

Grammar

The following is the general syntax for deleting MySQL data tables:

DROP TABLE table_name ;

Delete the datasheet in the command prompt window

In the mysql > command prompt window, delete the data table SQL statement is DROP TABLE :

Example

The following example deletes the data table runoob_tbl :

root@host# mysql -u root -p
Enter password:*******
mysql> use RUNOOB;
Database changed
mysql> DROP TABLE runoob_tbl;
Query OK, 0 rows affected (0.8 sec)
mysql>

Use the PHP script to delete the data table

PHP usage mysqli_query Function to delete the MySQL data table.

This function takes two arguments and returns TRUE on successful execution, or FALSE otherwise.

Grammar

mysqli_query(connection,query,resultmode);

Parameters.

Description

connection

Necessary. Specifies the MySQL connection to be used.

query

Required, specify the query string.

resultmode

Optional. A constant. It can be any of the following values:

  • MYSQLI_USE_RESULT(如果需要检索大量数据,请使用这个)

  • MYSQLI_STORE_RESULT(默认)

Example

The following example uses a PHP script to delete a data table runoob_tbl :

Delete database

<?php$dbhost='localhost';//mysql服务器主机地址$dbuser='root';//mysql用户名$dbpass='123456';//mysql用户名密码$conn=mysqli_connect($dbhost,$dbuser,$dbpass);if(!$conn){die('连接失败:'.mysqli_error($conn));}echo'连接成功<br
/>';$sql="DROP TABLE
runoob_tbl";mysqli_select_db($conn,'RUNOOB');$retval=mysqli_query($conn,$sql);if(!$retval){die('数据表删除失败:'.mysqli_error($conn));}echo"数据表删除成功\\n";mysqli_close($conn);?>

After the execution is successful, we will not see it when we use the following command runoob_tbl Table:

mysql> show tables;
Empty set (0.01 sec)
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.