The following views are supported by SAP HANA:
You can define database views using SQL DDL Statements. This is the only option covered in this course.
You can define Calculation Views or, more generally, information models using SAP HANA Tools. You can define views using Core Data Services and the HANA Development Perspective in the SAP HANA Tools. Information models and Core Data Services are used in HANA-specific data modelling and outside the scope of this course.
Note
Calculation Views and Core Data Services may be more powerful than SQL views, or may simplify the development process. Nevertheless, this course only covers SQL views. Understanding them is the foundation for understanding the other types of views and can be helpful for prototyping or analyzing issues.
Database Views: Advantages
Database views provide the following advantages:
De-couple applications from lower levels (relative to the three level schema architecture).
You can use database views to change to the conceptual schema (for example, add columns to a table) without causing side effects on applications.
Create views tailored to the users (applications) and their needs.
The application programmers do not have to know the full database structure but only the excerpt that is relevant to them.
Simplify queries.
Complex queries referencing views are easier to formulate, provided that the view provides an appropriate pre-selection of data.
Limit access to data.
You can use views to realize value-dependent access privileges or to make sure certain columns are never visible for certain users.
A Sample View: Red Cars
Example of a view containing only red cars:
1234567CREATE VIEW redCars
AS
SELECT CarID, Color, PlateNumber, HP AS Power
FROM Car
WHERE Color = 'red';| CARID | COLOR | PLATENUMBER | POWER |
|---|---|---|---|
| F01 | red | HD-V 106 | 75 |
| F09 | red | HD-UP 13 | 105 |
| F12 | red | HD-XY 4711 | 105 |
| F13 | red | HD-IK 1001 | 136 |
| F18 | red | HD-MQ 2006 | 90 |
Using Views in Queries
You can select data from a view in the same way you select from a table.
Which red cars have more than 100 HP?
1234SELECT CarID, PlateNumber, Power
FROM redCars
WHERE Power > 100
ORDER BY Power DESC, CarID ASC;In this example, the redCars view would have listed all red cars, but the addition of the WHERE clause further reduced the result set to red card with more than 100 HP.
| CARID | PLATENUMBER | POWER |
|---|---|---|
| F13 | HD-IK 1001 | 136 |
| F09 | HD-UP 13 | 105 |
| F12 | HD-XY 4711 | 105 |
