MySQL Delete Data Sheet

Source: Internet
Author: User
Tags mysql delete

MySQL Delete Data Sheet

Deleting a data table in MySQL is very easy to do, but you should be careful when you delete a table, because all the data disappears when you execute the delete command.

Grammar

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

;
To delete a data table in a command prompt window

Delete the data table in the Mysql> Command Prompt window The SQL statement is drop table :

Instance

The following example deletes the data table tutorials_tbl:

[Email protected] # mysql-u root-pEnter password:* ******mysql>use tutorials;  Database changedmysql> DROP TABLE tutorials_tblQuery OK,0(0.8  SEC)mysql>             
Delete a data table using a PHP script

PHP uses the mysql_query function to delete MySQL data tables.

The function has two parameters, returns TRUE on successful execution, or FALSE.

h3> syntax

BOOL mysql_query( sql,);    
Parameters Description
Sql Necessary. Specifies the SQL query to send. Note: The query string should not end with a semicolon.
Connection Optional. Specifies the SQL connection identifier. If not specified, the previous open connection is used.
Instance

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

<title>Creating MySQL Tables</title><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 Delete data table

Related Article

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.