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. The following is the general syntax for deleting MySQL data tables: In the mysql > command prompt window, delete the data table SQL statement is DROP TABLE : The following example deletes the data table PHP usage This function takes two arguments and returns TRUE on successful execution, or FALSE otherwise. 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(默认) The following example uses a PHP script to delete a data table Delete database After the execution is successful, we will not see it when we use the following command Grammar ¶
DROP TABLE table_name ;
Delete the datasheet in the command prompt window ¶
Example ¶
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 ¶
mysqli_query
Function to delete the MySQL data table.Grammar ¶
mysqli_query(connection,query,resultmode);
Example ¶
runoob_tbl
:<?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);?>
runoob_tbl
Table:mysql> show tables;
Empty set (0.01 sec)