SQL Server CREATE View

Source: Internet
Author: User

What is the view we all know that our country is now "God seven" heaven. From the lunar moon landing in the United States, the human God is no longer a myth. I heard that in the United States, you only have hundreds of thousands of dollars, you can go to the Moon for space travel, so we believe that: in the near future, the sky will come into our people's lives, it is a very new and magical things ah. A lot of Americans last day, they use binoculars to watch our earth, the result of seeing the shape of the earth is different. Some say like the green oranges, some say like the big white pear, some say like the big blue watermelon. What is this for? You're going to say, "That's because you see different shapes from different angles (perspectives)." So, from a different perspective, you'll see different "graphs," which is the view we'll talk about right away. Our student information is the same: for the student's information and results, the teacher is more concerned about the student's performance and whether to take the exam, including name, school number, written test, test, whether through. The class teacher is more concerned about the student file, including name, school number, gender and age. In fact, a view is a virtual table, which represents a table of partial data or multiple tables of comprehensive data, its structure and data is based on the query on the table basis • The view does not store data, but rather in the original table referenced by the view (base table) • The same original table, depending on the different needs of different users, The use of different view views can be created – filter rows in tables – Prevent unauthorized users from accessing sensitive data – Reducing database complexity – abstracting multiple physical databases into a single logical database using views can bring users and developers a very Many benefits. The specific:1. Benefits for end users (1The results are easier to understand when you create a view, you can change the column name to a meaningful name, making it easier for users to understand what the column represents. Modifying column names in a view does not affect the column names of the base tables. (2getting data is much easier for many people to understand SQL, so it is difficult for them to create complex queries over multiple tables. You can make it easier for users to access data in multiple tables by creating a view. 2. The benefits to developers (1restricting data retrieval makes it easier for developers to hide the information in some rows or columns at times. By using views, users have the flexibility to access the data they need while guaranteeing the security of other data in the same table or other table. To achieve this goal, you can exclude columns that are confidential to users when you create the view. (2maintaining an application makes it easier to debug a view than to debug a query. It is easier to track errors in each step of a process in a view because all the steps are part of the view. How to create a view • Use T-SQL statement syntax for creating viewsCREATE VIEWview_name as    <SELECT statement>IF EXISTS(SELECT *  fromsysobjectsWHERE /*detect if there is*/name= 'View_stuinfo_stumarks')     DROP VIEWView_stuinfo_stumarks/*Delete a view*/GOCREATE VIEWView_stuinfo_stumarks/*Create a View*/   as    SELECTName=Stuname, School Number=Stuinfo.stuno, written results=Writtenexam, machine test results=Labexam, average score=(Writtenexam+Labexam)/2                fromStuinfo Left JOINStumarks onStuinfo.stuno=Stumarks.stunoGOSELECT *  fromView_stuinfo_stumarks/*Working with views*/The structure and data of a virtual table exported from one or more tables or views is based on the query on the table. Theoretically it can be used like a normal physical table, such as adding, deleting, changing, checking, and so on, modifying the data in the view to actually modify the original data table. Because there are many limitations to modifying views, the general view is only used for queries in the actual development. 

SQL Server CREATE View

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.