Managing views in a database
View database objects allow the result of a query to be stored. In Amazon Redshift, views run each time the view is mentioned in a query. The advantage of using a view instead of a table is that it can allow access to only a subset of data on a table, join more than one table into a single virtual table, and act as an aggregated table, and it takes up no space on the database since only the definition is saved, hence making it convenient to abstract complicated queries. In this recipe, we will create views to store queries for the underlying tables.
Getting ready
To complete this recipe, you will need everything mentioned in the Technical requirements section at the start of the chapter.
How to do it…
Let’s create a view using the CREATE VIEW command. We will use the following steps to create a view:
- Create a
finance.customer_vwview based on the results of the query onfinance.customer:CREATE VIEW finance...