thing

One: the four characteristics of things

1. Atomicity All operations of the whole thing, either all are done or not all are done. It is impossible to stop in an intermediate state. When something goes wrong during execution, it is rolled back to the state it was in before the thing started, as if the thing was never executed.

2. Consistency Before things start and after things end, the integrity constraints of the database are not broken.

3. Isolation: The isolated state executes things so that they appear to be the only operations the system performs at a given time. If there are two things, running at the same time, performing the same function. The isolation of things will ensure that each thing in the system thinks that only that thing is using the system. This property belongs to serialization, in order to prevent confusion between the operations of things.

4. Persistence After the thing is completed, the changes made to the database by the thing will be persisted in the database and will not be rolled back.

Two: isolation level

isolation level dirty read non-repeatable read hallucinations
Read uncommitted Yes Yes Yes
Read committed no Yes Yes
Repeatable read no no Yes
Serializable (serialization) no no no

Read Uncommitted: A dirty read is when a transaction reads an uncommitted transaction

Read Committed: Modifications made before things are committed are invisible to other things.

Repeatable read: Ensure that the results of multiple identical queries in the same transaction are consistent. For example, a transaction starts to query a record and then executes the same query a few seconds later, ensuring that the results of the two queries are the same.

Serializability: Serializability is to ensure that no new data is inserted in the read range, such as a certain range of data obtained by the first query of a transaction. The second query also obtains the same range of data, and no new data is inserted into the range.

Three: MySQL creates a stored procedure

1. The advantages of MySQL stored procedures are mainly execution efficiency and SQL code encapsulation.

2. Create a MySQL stored procedure

create procedure pr_add(

a int,b int

)

begin

declare c int;

if a is null then set a=0;

end if;

if b is null then set b=0;

end if;

set c= a+b;

select c as sum;

Three Oracl

1. A stored procedure is a set of SQL statements that are compiled and stored in the database in order to complete a specific function. The user executes it by specifying the name of the stored procedure and giving parameters. Stored procedures are an important object in data, and any well-designed database application should use stored procedures.

2. Advantages of stored procedures

* Allows modular programming, which means that you only need to create a procedure once, and you can call the procedure any number of times later in the program.

* Allows faster execution If an operation requires a large number of SQL statements or repeated execution, stored procedures are faster than SQL statements.

* Reduce network traffic such as an operation that requires hundreds of lines of SQL code to complete a single execution statement without sending hundreds of lines of code over the network.

* Better security mechanism, users who do not have permission to execute stored procedures can also authorize them to execute stored procedures.

Four: What are the characteristics and differences between stored procedures and stored functions?

Features:

1. The realization of the stored procedure is a little more complicated, while the realization of the function is more targeted.

2. For stored procedures, parameters can be returned, while functions can only return values ​​or table objects.

3. Stored procedures are generally executed as a separate part, while functions can be called as part of a query statement. Since the function can return a table object, it can be placed after the from keyword in the query statement.

the difference:

1. Functions must have return values ​​and stored procedures do not

2. Functions can be executed individually, while procedures must be executed through execute

3. Functions can be embedded in SQL statements but not procedures

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325345210&siteId=291194637