I understand that a view is only a saved SQL query that can be considered as a virtual table. However, it seems to me that there is not much difference between creating a new table using the SELECT INTO statement and creating a view. What are some of the major distinctions between the two methods? Under what situations would you use one or the other?
Let's start with aknowledging that by what you say about views, you are not talking about indexed views. Because these are actually implemented with existing tables in the background. So, we are talking about non-indexed views.
The two methods are very different - in fact, they have nothing in common. It is strange, because you both mention:
Isn't this a contradiction? The result of select into
is actually a table, a view is not.
Not sure why are you asking about this or what are you trying to accomplish. In my experience, I use select into to fastly create logically temporary tables that have the same columns with the original without having to type all columns. This method of creating tables is generally inferior to the create table
command and a subsequent insert, because no indexes and other stuff can be made - thus its use in adhoc queries or as a temporary entity.