Tutorial _ MySQL

Source: Internet
Author: User
This article describes how to delete a table in MySQL. it is the basic knowledge in MySQ learning. it is easy for anyone who needs to discard a table in MySQL. However, you must be very careful when deleting any existing table and cannot recover it because of data loss.
Syntax:

Below is a general SQL syntax discard (delete) MySQL table:

DROP TABLE table_name ;

Delete a table from a command prompt:

Run the drop table SQL command at the mysql> prompt.
Example:

The following is an example of deleting a table tutorials_tbl:

root@host# mysql -u root -pEnter password:*******mysql> use TUTORIALS;Database changedmysql> DROP TABLE tutorials_tblQuery OK, 0 rows affected (0.8 sec)mysql>

Use a PHP script to delete a MySQL table:

To delete any database in an existing table, you need to use the PHP function mysql_query (). The table will be deleted using the correct SQL command using its second parameter.
Example:

Creating MySQL Tables -by www.bitsCN.com<?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
';$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);?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.