Transactions, triggers, functions, views, stored procedures

What is a transaction and what are the characteristics of a transaction?

Affairs:

The so-called transaction is to process multiple things according to one thing. In mysql, it is a user-defined sequence of operations. These operations are either done or not done, and are an inseparable unit. For example, if you go to the bank to withdraw money, enter a password, fill in an order form, a staff member operates a computer, a money detector checks money, and withdraws the money to give you, this series of operations are inseparable, all execution is a process must be performed Just finish

The transaction processing operation is large and the data with high complexity, such as deleting a student's information, deleting basic information, related class information, grades, and assessment information, all add up to form a transaction;

To use ACID to meet the transaction;

feature:

ACID of the transaction, atomicity, consistency, isolation and continuity;

Atomic, the transaction is the logical work unit of the database, the operations in the transaction are a whole;

Consistency, the execution result of the transaction must be to make the database change from one consistent state to another consistent state, if an error occurs so that a part has been written to the database, then the consistency is violated;

Isolation, when the transaction is executed, other transactions cannot interfere, each transaction is isolated from the other, and cannot interfere with each other. For example, when using data, to avoid the simultaneous execution of two transactions, the data used is the same group data;

Persistence, once the transaction is committed, the changes to the database are permanent, and if there is no change, it will always exist in it;

Briefly describe what are the triggers, functions, views, and stored procedures?

trigger:

Trigger is a special stored procedure that uses the code block that is automatically executed when mysql is inserted, updated, and deleted. The trigger must be defined on a specific table and executed automatically. It cannot be directly transferred;

The ORACLE database has four triggers, namely DML, instead-of, DDL, and DB triggers. DML and instead-of triggers are used in general application systems. DDL and DB triggers are managed by DBA The database is used more;

function:

Functions and stored procedures are similar, are a set of sql set, the function must have a return value, the function is generally used to implement simpler targeted functions (such as seeking absolute values, return the current time, etc.), the stored procedure is used Implement complex functions (such as complex business logic functions);

view:

The view is just a logical object, a virtual table, not a physical object. The table queried in the view is called the base table of the view;

The advantage is that the data used by the user can be centralized, the complexity of data viewing can be reduced, and what you want and what you want to display can be seen at a glance, simplifying permission management

Stored procedure:

Stored procedures are similar to functions, not return, which is to encapsulate a piece of code. When you want to execute, you can directly call this stored procedure to achieve what you want to do in advance. There can be judgment statements and loop statements inside the package;

Published 5 original articles · Liked4 · Visits16

Guess you like

Origin blog.csdn.net/qq_45218334/article/details/105618944