Hi This tutorial explains what VIEWS are and how are they created. My Question is that why do we need VIEWS for? Why cannot we use the normal SELECT command and fetch records directly from the main table instead of creating a VIEW first and then display records? Thanx
There are two reasons: security, and writing complex queries. In large databases, the database administrator will create views that contain all the information a given person needs to work with. Instead of querying the database directly, the person can query the view. With property security in place, a person can only access the view(s) that they have permission to read and write to. Once you work with SQL enough you'll run into certain problems that need to be solved with views. These queries are usually a pain, and until you run into one, it will be hard to grasp the utility of a view. Also, you can use views to reuse your code. For example, if you need to write 10 queries, and each query joins 4 tables together, you would make a view containing the SQL to join those 4 tables and then call the view from each of the 10 queries in order to save time.
I'm also suggesting you to read this Wiki "http://en.wikipedia.org/wiki/View_(database)" article about views. "A view is a pre-compiled virtual table...", - also a reason to use views.