Common database statements (4)

Source: Internet
Author: User
Tags rollback

Grouping
SELECT
COUNT (*) sum,
Book_name,
Bokk_author
From
Book
GROUP by
Bokk_author
Having
Sum > 3;

Simple difference between drop truncate delete (to be perfected)

DORP table structure will be deleted, all deleted
Truncate clears the table data, deletes the entire data
Delete Deletes data and deletes some functions with delete

TRUNCATE TABLE author
DROP TABLE Test
Delete from author where author_name = "HHQ"

Union\union All Union query
The Union and UNION ALL keywords combine two result sets into one, and two tables have the same number of columns
Union can be de-weighed, union all shows all

Select Bokk_author from book union ALL select Author_name from author;
Select Bokk_author from book Union select Author_name from author;


Transaction processing

There are two main methods of MySQL transaction processing:
1, with Begin,rollback,commit to achieve

Begin a transaction
ROLLBACK TRANSACTION Rollback
Commit TRANSACTION Acknowledgement

Begin
Delete from author;
Select from author;
ROLLBACK;
SELECT
from author;
COMMIT;
2. Change MySQL auto-commit mode directly with Set
Set autocommit=0 prohibit auto-commit
Set autocommit=1 turn on auto-commit

Common database statements (4)

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.