Simple data removal

Source: Internet
Author: User

The SQL statement to delete the data is very simple, as long as we specify the table to be deleted, such as we want to delete the data in the T_DEBT and T_person tables, then execute the following SQL statement:

DELETE FROM T_Debt;DELETE FROM T_Person;

Because the Fperson field in the T_debt table is a foreign key to the FName field of the table T_person, you must first delete the data in the T_DEBT table before you can delete the data in T_person.

Perform a SELECT * from T_DEBT View the data changes in the T_DEBT table.

Execute the SELECT * from T_person after executing this SQL statement to view the data changes in the T_person table.

You can see that all rows of data in the table have been deleted, and there is no data in t_debt and T_person.

Beginners tend to confuse the drop TABLE statement with the delete, although both names have "delete" two words, but the DELETE statement simply deletes the rows of data in the table, and the structure of the table exists, and the drop TABLE statement will not only delete the rows of data in the table, It also removes the structure of the table. An image can be likened to a DELETE statement that simply "eats up the meal in the bowl," while the drop TABLE statement "eats up the bowl and smashes the bowl." If we execute "DROP table T_person" Then the database system will report "data table T_person not present" when executing "SELECT * Fromt_person" again.

The DELETE statement above deletes all the data in the table, so what if we just want to delete the data rows we specified? Like the UPDATE statement, the DELETE statement also provides a where statement to filter the data so that only rows that meet the filter criteria are deleted.

Simple data removal

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.