What are the benefits of using MySQL views as compared to selecting data directly from MySQL base tables?

MySQLMySQLi Database

As we know that views are definitions built on the top of other tables or views and stored in the database. Followings are benefits of using MySQL views as compared to selecting data directly from MySQL base tables

Simplify data access

  • The use of views simplifies the data access because of the following reasons −
  • A view can be used to perform a calculation and display its result. For example, a view definition that invokes aggregate functions can be used to display a summary.
  • With the help of views, we can select a restricted set of rows by means of an appropriate WHERE clause or select only a subset of a table’s column.
  • With the help of views, we can select data from multiple tables by using a join or union.

The above-mentioned operations can be performed automatically by using views.

Improves data security

We can use views to display user-specific contents, this improves the security as no user can able to access or modify the data related to other users.

Reduce data distraction

Views do not show the irrelevant column hence they reduce data distraction.

Preserves the appearance of original table structure

A view can preserve the appearance of the original table structure to minimize disruption to other applications. It would be useful if we want to change the structure of a table to accommodate certain applications.

Implements all queries

All the queries can be implements on views as we can implement on a base table. Basically, we can use any clause in views and views can be used in INSERT/UPDATE/DELETE. We can create views of other views.

raja
Updated on 22-Jun-2020 12:57:20

Advertisements