Home  >  Article  >  Database  >  How to create a view using SQL statements in navicat

How to create a view using SQL statements in navicat

angryTom
angryTomOriginal
2019-08-09 10:46:258310browse

How to create a view using SQL statements in navicat

navicat is a very easy-to-use database management software with very powerful functions. Below we will introduce to you how to use sql statements to create views in navicat.

Recommended tutorial: navicat graphic tutorial

First we need to open navicat. Select the database to be operated on. Click Query to create a new query. Use the create view statement to create a view.

create view View_name 
as
   select * from table_name where Mid>1

Then click Run to create the view.

Extended information: The role of views

The first point: Using views, you can customize user data and focus on specific data.

Explanation:

In the actual process, the company has staff with different roles. If we take a sales company as an example, the purchasing staff may need some data related to them, and Data that has nothing to do with him has no meaning to him. We can create a view specifically for the purchasing staff based on this actual situation. When he queries the data in the future, he only needs to select * from view_caigou.

Second point: Using views can simplify data operations.

Explanation:

When we use queries, we often need to use aggregate functions, and at the same time, we also need to display information about other fields, and may also need to associate it with other tables. The statement written at this time may be very long. If this action occurs frequently, we can create a view. From then on, we only need to select * from view1~, isn't it very convenient~

Third point: Using views, the data in the base table has a certain degree of security

Explanation:

Because the view is virtual and does not exist physically , it just stores a collection of data. We can provide important field information in the base table to the user without using the view. The view is a dynamic collection of data, and the data is updated as the base table is updated. At the same time, users cannot change or delete views at will, which ensures data security.

The fourth point: You can merge separated data and create a partitioned view (//I have not used it currently)

Explanation:

With With the development of society and the continuous expansion of the company's business volume, a large company has many branches. For the convenience of management, we need to unify the structure of the table, regularly check the business status of each company, and look at each company separately. The data is very inconvenient and not very comparable. It would be much more convenient if these data were merged into one table. At this time, we can use the union keyword to merge the data of each branch into one view.

The above is the detailed content of How to create a view using SQL statements in navicat. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn