Hal ini sangat mudah untuk menghapus tabel MySQL yang ada. Tapi Anda harus sangat berhati-hati saat menghapus setiap tabel yang ada karena data yang hilang tidak akan pulih setelah menghapus tabel.
Syntax:
Berikut ini adalah sintaks SQL generik untuk drop tabel MySQL:
DROP TABLE table_name ;
Menjatuhkan Tabel dari Command Prompt:
ni hanya membutuhkan untuk mengeksekusi perintah SQL DROP TABLE di prompt mysql>.
contoh:
Berikut adalah contoh yang menghapus tutorials_tbl:
root@host# mysql -u root -p Enter password:******* mysql> use TUTORIALS; Database changed mysql> DROP TABLE tutorials_tbl Query OK, 0 rows affected (0.8 sec) mysql> Menjatuhkan Tabel Menggunakan PHP Script: Contoh
<html> <head> <title>Creating MySQL Tables</title> </head> <body> <?php $dbhost = 'localhost:3036'; $dbuser = 'root'; $dbpass = 'rootpassword'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully<br />'; $sql = "DROP TABLE tutorials_tbl"; mysql_select_db( 'TUTORIALS' ); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not delete table: ' . mysql_error()); } echo "Table deleted successfully\n"; mysql_close($conn); ?> </body> </html>