Views in SQL
Sample table:Student_Detail
Student_Marks
1. Creating viewA view can be created using the CREATE VIEW statement. We can create a view from a single table or multiple tables. Syntax: 2. Creating View from a single tableIn this example, we create a View named DetailsView from the table Student_Detail. Query: Just like table query, we can query the view to view the data. Output:
3. Creating View from multiple tablesView from multiple tables can be created by simply include multiple tables in the SELECT statement. In the given example, a view is created named MarksView from two tables Student_Detail and Student_Marks. Query: To display data of View MarksView:
4. Deleting ViewA view can be deleted using the Drop View statement. Syntax Example: If we want to delete the View MarksView, we can do this as: Next TopicDBMS SQL Index
|