Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is view in Sql server

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 338
    Comment on it

    A View is a virtual table which is created form another table and its content are defined by a query. In real scenarios we use views for security purpose by allowing users to access data through the view, without granting the users permissions to directly access the underlying base tables.
    For an illustration: We have a customer table with the fields ('id', 'name', 'age', 'address', 'salary') but if we want to customize the perception each user has of the database and to show a table with the fields having only 'name' and 'age' then we can create view for that fields. We are having 'CUSTOMERS' table
    alt text

    Now, following is the example to create a view from CUSTOMERS table.

    SQL > CREATE VIEW CUSTOMERS_VIEW AS
    SELECT name, age
    FROM  CUSTOMERS;
    

    Now, you can query CUSTOMERS_VIEW in similar way as you query an actual table. Following is the example:

    SQL > SELECT * FROM CUSTOMERS_VIEW;
    

    This would produce the following result:

    alt text

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: