Implementing Db2 views

When you design your database, you might need to give users access to only certain pieces of data. You can give users access by designing and using views.

Use the CREATE VIEW statement to define and name a view. Unless you specifically list different column names after the view name, the column names of the view are the same as the column names of the underlying table. When you create different column names for your view, remember the naming conventions that you established when designing the relational database.

A SELECT statement describes the information in the view. The SELECT statement can name other views and tables, and it can use the WHERE, GROUP BY, and HAVING clauses. It cannot use the ORDER BY clause or name a host variable.

You can use views to perform the following tasks:

  • Control access to a table
  • Make data easier to use
  • Simplify authorization by granting access to a view without granting access to the table
  • Show only portions of data in the table
  • Show summary data for a given table
  • Combine two or more tables in meaningful ways