Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL View vs Derived Table

I've always thought of a View as a stored query. Recently I needed to use Derived Tables in a project. That got me thinking about Views.

Isn't a View the same thing as a Derived Table except that it has been saved as a logical entity where a Derived Table is built on the fly?

like image 700
Michael Riley - AKA Gunny Avatar asked Apr 06 '12 13:04

Michael Riley - AKA Gunny


1 Answers

Yes, for most intents and purposes they can be thought of as you described. They are the same idea.

In some RDBMS you can do more interesting things with a view. Indexing is the first that comes to mind. You can also grant access restrictions to views as they are proper database objects.

Take a look at "Derived Tables in SQL" for more information.

like image 139
Yuck Avatar answered Oct 30 '22 07:10

Yuck