Your browser does not support JavaScript. This help page requires JavaScript to render correctly.
Skip Headers
Previous
Previous
 
Next
Next

Example: Creating a View

In this example, you create a view named king_view, which uses the hr.employees table as its base table. (The hr schema is part of the sample schemas.) This view filters the table data so that only employees who report directly to the manager King, whose employee ID is 100, are returned in queries. In an application scenario, this view adds an additional level of security to the hr.employees table while providing a suitable presentation of relevant information for manager King.

To create the KING_VIEW view on the HR.EMPLOYEES table:

  1. Go to the Database Home page, logging in as user hr or as user SYSTEM.

    See "Accessing the Database Home Page".

  2. At the top of the page, click Schema to view the Schema subpage.

  3. In the Database Objects section, click Views.

    The Views page appears.

  4. Click callbackCreate.

    The Create View page appears.

  5. Enter the following information:

    • In the Name field, enter king_view.

    • In the Schema field, enter hr.

    • In the Query Text field, enter the following SQL statement:

      SELECT * FROM hr.employees
      WHERE manager_id = 100
      
  6. Click OK.

    The Views page returns and displays a confirmation message. The new view appears in the list of views.

To test the new KING_VIEW view:

  1. On the Views page, select king_view and then select View Data from the Actions list.

  2. Click Go.

    The View Data for View page appears. The data selected by the view appears in the Result section.

  3. (Optional) You can also test the view by submitting the following SQL statement in SQL*Plus or SQL Developer:

    SELECT * FROM king_view
    

Related Topics

About Views