Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

017-mysql question and answer

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MySql question and answer

1. The difference between drop and delete truncate?

All three mean to delete, but there are some differences among the three:

Delete and truncate only delete the table's data, not the table's structure.

Drop deletes the entire table

When you want to delete some data, you should delete delete with where statement.

Use truncate when you want to delete all data while preserving the table structure

2. The role of the transaction

Transaction is the basic unit of concurrency control. A transaction is a series of operations that are either performed or not performed.

Transactions have the following four basic characteristics:

A series of operations in Atomic (atomic) transactions either complete or fail

Consistency (consistency) A successful transaction should write data to the database, otherwise it will be rolled back to its original state

Isolation (isolated) concurrent access and modified duli

Durability (persistence) the end of a transaction should be stored according to the transaction processing structure.

Statement of the transaction:

Start things: BEGIN TRANSACTION

Submit things: COMMIT TRANSACTION

Rollback transaction: ROLLBACK TRANSACTION

3. Optimistic lock (shared lock) and pessimistic lock (exclusive lock) in database

Different lock permissions can be set on data according to different types.

* * optimistic | pessimistic lock is mainly used for concurrent access control * *

Pessimistic locks assume that concurrency conflicts will occur, blocking any operations that violate the integrity of the data

Optimistic locks assume that there will be no conflicts, only to check whether the data integrity is violated when submitting the operation.

4. Can the function of the view be changed?

A view is a virtual table, and unlike a table that contains data, a view contains only queries that retrieve data dynamically when used; it does not contain any columns or data. Views can be used to simplify complex sql operations, hide details, and protect data; after views are created, they can be used to modify data in the same way as tables.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report