Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it bad to call views inside a View in sql

Tags:

sql

sql-server

I have created 8 different views and i am using all these views inside a view. So i was wondering before i go any further with this idea. i want to know does it affects performance too badly or not.

like image 419
madhu.13sm Avatar asked Oct 10 '12 19:10

madhu.13sm


People also ask

Can a view reference a view?

Note: You can place a view reference on other views. If you try to reference the current view on a sheet, no symbol is placed. Open the view to which you want to add a reference. Note: If the view is on a sheet, right-click the view, and click Activate View.

Can we create a view on top of a view?

You can certainly have a view that's built on top of another view: create table my_table (id number, name varchar2(20), address varchar2(30)); table MY_TABLE created.

Can we create a view from another view in SQL?

Creating ViewsViews can be created from a single table, multiple tables or another view. To create a view, a user must have the appropriate system privilege according to the specific implementation. CREATE VIEW view_name AS SELECT column1, column2..... FROM table_name WHERE [condition];

What is nested views in SQL?

Views – pitfallsThe chief risk coming when one view refers to another which in turn refers to another – this is known as a nested view and to your grizzled DBA sets the alarm bells ringing.


1 Answers

No, it's fine. In many cases I personally consider it preferable to writing one view with a giant and difficult to understand definition. In my opinion, using multiple views allows you to:

  1. Encapsulate discrete logic in individual views.
  2. Re-use logic in the individual views without having to repeat the logic (eliminating update problems later).
  3. Name your logic so that it's easier for the next programmer to understand what you were trying to accomplish.
like image 112
Larry Lustig Avatar answered Oct 18 '22 21:10

Larry Lustig