Wu Yuxiong - natural born MySQL study notes: MySQL delete data table

MySQL to delete the data table is very easy to operate, but when you delete the table during the operation to be very careful, because the delete command all data will be lost. 
Syntax 
The following is the general syntax delete MySQL data tables: 
DROP TABLE table_name;
Delete data table in the command prompt window 
in MySQL > Command Prompt window, delete data table SQL statement DROP TABLE: 
The following example deletes the data table runoob_tbl: 
root @ Host # MySQL -u root -p 
the Enter password: ***** ** 
MySQL > use RUNOOB; 
Database changed 
MySQL > the DROP TABLE runoob_tbl 
Query the OK, 0 rows affected ( 0.8 sec) 
MySQL >
Use PHP script to delete data tables 
PHP using MySQL mysqli_query function to delete data tables. 
This function takes two arguments and returns TRUE if executed successfully, otherwise it returns FALSE. 
Syntax 
mysqli_query (connection, query, resultmode) ;

 

 

The following example uses a PHP script to delete the data table runoob_tbl:
 < PHP? 
$ Dbhost = ' localhost: 3306 ' ; // MySQL server host address 
$ dbuser = ' root ' ; // MySQL username 
$ dbpass = ' 123456 ' ; // mysql username and password 
$ Conn = mysqli_connect ($ dbHost, dbuser $, $ dbpass);
 IF ($ Conn!) 
{ 
  Die ( ' connection failed: ' . mysqli_error ($ Conn)); 
} 
echo ' successful connection <br /> ' ; 
$ SQL =" The DROP TABLE runoob_tbl " ; 
mysqli_select_db ($ Conn, ' RUNOOB ' ); 
$ retval = the mysqli_query ($ Conn, $ SQL);
 IF ($ retval!) 
{ 
  Die ( ' data table deletion failed: ' . Mysqli_error ($ Conn) ); 
} 
echo " data table deleted successfully \ the n- " ; 
mysqli_close ($ conn); 
? >

 

Guess you like

Origin www.cnblogs.com/tszr/p/12113103.html