Creating a View

Previous
Previous
Next
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:

  1. Log in to the Database Home Page. See "Logging in to the Database Home Page".

  2. On the Database Home Page, click the Object Browser icon.

  3. In the Detail pane, select Views from the Create menu.

  4. In the View Name field, enter the name of the view (my_emp_view).

  5. Click Query Builder to build the query for the view.

  6. Click the departments table, and select the department_id, department_name, and manager_id columns.

  7. Click the employees table, and select the employee_id, first_name, and last_name columns.

  8. 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.

  9. 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.

  10. Click the Run button to see the results of querying this view.

  11. Click the Return button to return to Object Browser.

  12. Click the Next button.

  13. Click the SQL button to view the SQL statement that creates the view.

  14. Click the Create button to create the view.