View (views):
Virtual tables
Mainly used to see (check) the data
The data changes in the base table are reflected in the view
Permission control
Integrate the results of multi-table queries into the view for easy viewing by users
Create VIEW v1 as SELECT ... Query statements
With CHECK option-the inserted data, which can be queried by the view, conforms with CHECK option otherwise it does not conform
DROP VIEW IF EXISTS t_student;
CREATE VIEW T_student as
SELECT * FROM Student
With CHECK OPTION;
The view is to query all the records in the student table, and the statements that are updated are as follows.
1 INSERT into ' t_student ' VALUES (' 10004 ', ' Zhao Liu ', +, ' wang123 '); --Insert if other unassigned fields have default values, can be inserted, if no error
2 UPDATE t_student SET name= ' Zhao 62 ' where id= ' 10004 '; --Updates can
3 DELETE from t_student WHERE id = ' 10004 '; --Delete can also
Statistical information, function results can be made into a view
Show tables; See what views are available
Show CREATE View V1\g
Drop view if exists v1;
==========================================
Transaction
Begin a transaction
ROLLBACK TRANSACTION Rollback
Commit TRANSACTION Acknowledgement
MySQL provides multi-user concurrent access to data, the consistency of data, the integrity of a huge challenge.
The concurrency control function is provided by different database management systems.
Different development tools often also provide commands to implement database concurrency control.
Begin
SavePoint test; Save a point
Rollback to savepoint test;
Transaction (TRANSACTION):
Transactions are the basic unit of concurrency control
Only INNODB/BDB storage engine support transaction show Engines\g
Note Using the InnoDB storage engine when building a table
4 Features of a transaction:
Atomicity (atomicity): atoms mean the smallest particles, or things that cannot be divided, all statements that make up a transaction must either be executed or all canceled
Isolation (Isolation): operation of a transaction is not visible to other transactions
Persistence (Durability): When a transaction is complete, its effect should be preserved and cannot be undone
Consistency (consistency): a rule that refers to data, which should be consistent before/after a transaction
S1 read the data, S2 also access the same data, modify it, S1 reread, get the data is not the same, violate the consistency
Set autocommit=0 prohibit auto-commit
Set autocommit=1 turn on auto-commit
MySQL View, transaction