background image
<< Creating Views | Updating a View >>
<< Creating Views | Updating a View >>

Creating a View in SQL Script

Using Views
3-22 Oracle Database 2 Day Developer's Guide
5.
Click OK.
You created a new view. The equivalent SQL statement for creating this view follows:
CREATE VIEW salesforce AS
SELECT first_name || ' ' || last_name "Name",
salary*12 "Annual Salary"
FROM employees
WHERE department_id = 80;
In
Example 3­6
, you will create a view of all employees in the company and their work
location, similar to the query you used in
"Using Character Functions"
.
Example 3­6 Creating a View in SQL Script
CREATE VIEW emp_locations AS
SELECT e.employee_id,
e.last_name || ', ' || e.first_name name,
d.department_name department,
l.city city,
c.country_name country
FROM employees e, departments d, locations l, countries c
WHERE e.department_id=d.department_id AND
d.location_id=l.location_id AND
l.country_id=c.country_id
ORDER BY last_name;
The results of the script follow.
CREATE VIEW succeeded.
You have now created new view that relies on information in 4 separate tables, or a
4-way JOIN. In the Connections navigation hierarchy, if you click the 'plus' sign next
to Views, you will see
emp_locations
.