0

I've just started joining Stored Procedures together using views and it seems a simple way of building up a short query using the results of others.

Are there any disadvantages to over relying on Views before I plough on with this method? Am I better to pursue the temporary table option?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Mike
  • 537
  • 1
  • 8
  • 18

2 Answers2

0

The main differences are that a view only actually stores the query not the results (with the exception of materialised views) and views persist after the end of your session. Views are an excellent way of hiding complexity, but does not make the queries run more quickly than if you wrote out the whole thing in one query. Views also do not use up storage space (except for a very small amount for the metadata).

I would recommend using views if you do not have any requirements to speed the queries up further or if you need to be able to reference the data without recreating it subsequent sessions.

Temporary tables do store the result, but just for the current session, so if you need a base query to speed up further queries for the duration of your session, this can be useful.

ChrisProsser
  • 12,598
  • 6
  • 35
  • 44
0

In fact, views are mostly used for security reasons, and they also make queries more simple (for some cases.) So it just depends on what you are doing, based on if it requires storing and other requirements.

Kuzgun
  • 4,649
  • 4
  • 34
  • 48