Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Explanation of SQL Server View

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In the initial work, we need to do a system login verification, look through the login verification done by colleagues, and find that when colleagues do user name verification, the result set comes from a view, and I have done it before. However, I seldom take a closer look at the detailed knowledge about it, so I specially Google Baidu and summarize the following knowledge:

A view is a visualization table of the result set based on the SQL statement. From the user's point of view, a view looks at the data in the database from a specific perspective. From within the database system, a view is a virtual table defined by a query made up of SELECT statements. From the internal point of view of the database system, the view is composed of data from one or more tables. From the outside of the database system, the view is like a table, and the general operations that can be performed on the table can be applied to the view, such as query, insert, modify, delete and so on.

Personal understanding is: this table does not actually exist in DB, this table is a temporary table generated after the execution of the SQL statement, this table is undoubtedly in the system temporary table. Our additions, deletions, queries and changes to this table will not actually affect the real data.

The advantage of this is to take an example at work, for example, the user login verification verifies whether the user's password and user name are the same, assuming that the stored user information table also contains other confidential and sensitive data, if you look up this table directly, for example, using select * from, then this will export all the information, but also have unwanted memory cpu overhead. So create a view, find a virtual table for the fields that need to be validated, and then look for a match in that table. So that confidential information can be hidden. Of course, the view has other uses, as detailed in Baidu.

Actual creation: create a view

Create view LoginCheck asselect name, LogKey from security_user where security_user.normal = 1 union select name, LogKey from security_user where security_user.normal = 2

Work with views:

Select LoginCheck.name, LoginCheck.LogKey from LoginCheck

Change a view:

Alter LoginCheck as select name,LogKey from normal_user

Summary

The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report