In the previous segment, you learnt that CTEs are temporary tables that you can use in order to query data from a part of a huge data set. Now, what if you want to use the same subset of data for multiple queries? In such a case, instead of writing a CTE over and over again, you can store the required data on which you want to perform your analysis. This is what views are used for. You will understand the importance of using views better after watching the upcoming video.

Note that it is not necessary that views would always be preferred to CTEs. When you know for sure that you need to subset data from a table only once, you should use a CTE to avoid extra memory and space usage.

Report an error