2 Day Developer > Managing Database Objects > Managing Views > Creating a View
Creating a View |
Previous |
Next |
You can use Object Browser to create a view. The following example creates a view derived from the departments
and employees
tables to display department information along with the corresponding name of the manager.
This view combines the department_id
, department_name
, and manager_id
columns from the departments
table with the employee_id
, first_name
, and last_name
columns of the employees
table.
The tables are joined from the manager_id
of the departments
table to the employee_id
of the employees
table. This ensures that the corresponding first and last name of a manager is displayed in the view.
To create a view:
Log in to the Database Home Page. See "Logging in to the Database Home Page".
On the Database Home Page, click the Object Browser icon.
In the Detail pane, select Views from the Create menu.
In the View Name field, enter the name of the view (my_emp_view
).
Click Query Builder to build the query for the view.
Click the departments
table, and select the department_id
, department_name
, and manager_id
columns.
Click the employees
table, and select the employee_id
, first_name
, and last_name
columns.
Click the blank box to the right of manager_id
in the departments
table to choose this column for a join with the employees
table.
Click the blank box to the right of the employee_id
in the employees
table to choose this as the corresponding column for the join with manager_id
of the departments
table. Note the line that is added to the diagram connecting the two tables.
Click the Run button to see the results of querying this view.
Click the Return button to return to Object Browser.
Click the Next button.
Click the SQL button to view the SQL statement that creates the view.
Click the Create button to create the view.