1

I have this question, is there any performance issue with creating SQL view by joining two or more tables? Is it good practice or one should create another table with joins and create view on top of it?

ADITYA PAWAR
  • 198
  • 2
  • 13

2 Answers2

2

A view creates a logical table and that table can be the result of any SQL statement.

When you create a view, you remember these things:-

  • Limiting the visibility of columns (via select) or rows (via where) to just those pertinent to a task
  • Combining rows (via union) and or columns (via join) from multiple tables into one logical table.
  • Aggregating rows (via Group BY and Having) into a more distinct presentation pulled from a table with finer detail.

Views have the following benefits: (Refer by - What is a good reason to use SQL views?)

  • Security - Views can be made accessible to users while the underlying tables are not directly accessible. This allows the DBA to give users only the data they need while protecting other data in the same table.
  • Simplicity - Views can be used to hide and reuse complex queries.
  • Column Name Simplication or Clarification - Views can be used to provide aliases on column names to make them more memorable or meaningful.

Thanks!!!

Nitika Chopra
  • 1,281
  • 17
  • 22
  • Copied from https://stackoverflow.com/questions/2680207/what-is-a-good-reason-to-use-sql-views? – jarlh Feb 17 '20 at 10:07
  • @jarlh only benefits I copied - Actually I give full description which necessary for Aditya Pawar. If I any violation of rules giving answers then I can delete "benefits of views" in my answer. Reply, please – Nitika Chopra Feb 17 '20 at 10:17
  • 1
    You could have added a link to the original answer. – jarlh Feb 17 '20 at 10:26
0

Yes, you can create view by joining two or more tables. For more performance efficient views check on creating indexed views. Basically, views are used to hide the internal column and table details from user by providing only required interface(renamed columns and data).