Understanding Views in MySQL and MS SQL

What is a View?

A View looks and behaves just like a table, but it is generated. Most commonly, you create a view for a person or application to have access to a part of your database. You might simplify the data to just what people need to do adhoc queries, or you might provide an application the data it needs in a read-only view.

What’s in a View?

Would a view by any other name show the same data? It might, depending on the query that is used to dynamically construct the view. How do we see that query?

MySQL

SHOW CREATE VIEW databasename.viewname;

Microsoft SQL

EXEC sp_helptext 'databasename.viewname'

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.