This article will describe the impact on view containing select * from statement, if some column added in original table after the creation of view. Besides this, the write up contains simple query to create and alter view to give some ideas how to tackle such situation with an example.
What is View:
A view contains query to pull data from table. Views are virtual and those views run the query definition each time whenever we access.
Simple SQL Query to create View
Create view [dbo].[Demo_View] as select * from dbo.Customer
Here, Customer is original table and Demo_View is created by selecting all columns from Customer table for the moment.
If we change some columns in Customer Table then we need to run Alter View Query for Demo_View. Because, view is created with original table information including the previous columns. If we add some new columns in Customer, previously created view does not get newly updated or added changes in view automatically. Thus, view can throw error in your system. So, if we add something in original Table and our View contains Select * from statement in View using that Table then we need to Alter the query for view.
e.g. Query to Alter View
Alter view [dbo].[Demo_View] as select * from dbo.Customer
However, If we haven’t use select * from statement in View then it does not create any issue with View even though we add new column in original table.
e.g. Create view [dbo].[View_Report1] as Select Name, Address, PhoneNo, Email, Nationality from Customer
For this case, if we add any column in Customer Entity then it doesn’t affect view View_Report1
Hence, this article has described impact of column add in Table after creation of View using select * statement.