It is applicable to a updatable view. Uses of a View : A good database should contain views due to the given reasons: Restricting data access — Views provide an additional level of table security by restricting access to a predetermined set of rows and columns of a table. Hiding data complexity — A view can hide the complexity that exists in a multiple table join. Simplify commands for the user — Views allows the user to select information from multiple tables without requiring the users to actually know how to perform a join.
Store complex queries — Views can be used to store complex queries. Rename Columns — Views can also be used to rename the columns without affecting the base tables provided the number of columns in view must match the number of columns specified in select statement. Thus, renaming helps to to hide the names of the columns of the base tables. Multiple view facility — Different views can be created on the same table for different users. This article is contributed by Harsh Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.
See your article appearing on the GeeksforGeeks main page and help other Geeks. Views are used for security purposes because they provide encapsulation of the name of the table. Data is in the virtual table, not stored permanently. Views display only selected data. We can also use Sql Join s in the Select statement in deriving the data for the view. If we want to alter the view, then we can use the Alter View command to alter the view.
For example,. We can use the Drop command to drop a view. We can see the City column in the output. In the previous example, we modify the SQL table to add a new column. Suppose in the production instance, and you have a view in the application. You are not aware of the changes in the table design for the new column.
We do not want any changes to be made in the tables being used in the VIEW. Names must be in a two-part format, and an object cannot reference itself. In my query, I used a three-part object name in the format [DBName. We can use the two-part name as per the following query. We need to drop the VIEW definition itself along with other dependencies on that table before making a change to the existing table schema.
If we do not want users to view the definition, we can encrypt it. We need to note the following things regarding this. If we try to insert a value that does not match the condition, we get the following error message. Suppose we want to change the condition in the where clause of a VIEW. Execute the following query. The following code block has an example to update the age of Ramesh. Rows of data can be inserted into a view.
Rows of data can be deleted from a view. Obviously, where you have a view, you need a way to drop the view if it is no longer needed.
0コメント