Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding Views
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01587551
Message ID:
01587552
Vues:
54
J'aime (1)
>Hi,
>
>I have a general newbie question on SQL Server views.
>
>When you create a view, does SQL Server automatically maintain records in the view? Example. Say I create a view on records in a table that have value in column STATUS set to 'O' and in column CATEGORY to 'ABC'. Do I understand that whenever the base table (on which the view is created) gets records of STATUS 'O' and CATEGORY 'ABC', these records immediately are in the view? When when you, say, change the STATUS to 'C', the record is removed from the view (automatically) by SQL Server?

A view is executed on the fly; it does not already have the data stored and ready to be served up.

From - http://stackoverflow.com/questions/1278521/why-do-you-create-a-view-in-a-database

A view provides several benefits.

1. Views can hide complexity

If you have a query that requires joining several tables, or has complex logic or calculations, you can code all that logic into a view, then select from the view just like you would a table.

2. Views can be used as a security mechanism

A view can select certain columns and/or rows from a table, and permissions set on the view instead of the underlying tables. This allows surfacing only the data that a user needs to see.

3. Views can simplify supporting legacy code

If you need to refactor a table that would break a lot of code, you can replace the table with a view of the same name. The view provides the exact same schema as the original table, while the actual schema has changed. This keeps the legacy code that references the table from breaking, allowing you to change the legacy code at your leisure.

These are just some of the many examples of how views can be useful.
Brandon Harker
Sebae Data Solutions
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform