What is a view and why we use it ? can we create nested views ?
SQL
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
What is a view and why we use it ? can we create nested views ?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vijay Bansode14 reputationPosted Aug 14, 2025, 3:10 AM EDT
A View in SQL is like a saved query that acts like a virtual table.
Yes ? — you can create a view on top of another view.
-- First view CREATE VIEW vw_SalesSummary AS SELECT OrderID, CustomerID, TotalAmount FROM Sales; -- Nested view (uses first view) CREATE VIEW vw_HighValueSales AS SELECT * FROM vw_SalesSummary WHERE TotalAmount > 10000;But caution:
Too many nested views can reduce performance because SQL Server has to expand and run all underlying queries.
Debugging becomes harder when logic is buried inside multiple view layers.
Sometimes SQL Server has a nesting limit (e.g., 32 levels max).
Howher Michael131 reputationPosted Aug 20, 2025, 9:10 AM EDT
Hmm, I think a view is basically like a saved query in SQL. You use it so you don’t have to write the same complex query over and over. And yeah, I’ve tried creating nested views before, it works, but you just have to be careful about performance if the layers get too deep.