A view is a function that extracts and generates data from a single table or multiple tables connected by JOIN into a new window. There are two reasons for the wide use of the view function by database developers and administrators:
Manage database security
-The view can help protect sensitive data by hiding some sensitive information columns in the meta table. These meta tables can be a single actual table or JOIN tables, restrict the actual data rows that can be returned from these metabases, or decrypt the encrypted data that has been stored on the disk to implement database security management.
Optimize database performance
-A view can be used to optimize database performance. It is a multi-Table view created through a predefined fine-tuned JOIN condition, or, you can limit that only a small amount of data can be returned from a large database table.
The view function supported by MySQL5 can be used to execute certain UPDATE statements using views under certain conditions, so that the data can be updated. The following is an example:
mysql> select * from customer;+-------------+---------------------+--------------------+------------------+| customer_id | customer_first_name | customer_last_name | customer_ssn |+-------------+---------------------+--------------------+------------------+| 1 | fred | smith | ☼Q,U¶ ¢ƒ╠▒4╨☺ö| +-------------+---------------------+--------------------+------------------+ 1 row in set (0.03 sec)mysql> create view v_customer as t_name, -> select customer_id, customer_first_name, customer_last_name -> aes_decrypt(cusomer_ssn,'password') as customer_ssn -> from customer; Query OK, 0 rows affected (0.03 sec)mysql> select * from v_customer;+-------------+---------------------+--------------------+--------------+| customer_id | customer_first_name | customer_last_name | customer_ssn |+-------------+---------------------+--------------------+--------------+| 1 | fred | smith | 456097234 |+-------------+---------------------+--------------------+--------------+
As shown in the preceding example, you can use the decryption function aes_decrypt () to obtain the value of the specified mermer_ssn and create a view to display the value, the original table is not broken through the encrypted storage of other customer_ssn values on the disk or database. In this way, the administrator ensures that sensitive information is not damaged at will. (Bkjia.com tutorial)