How To Create a New View?
Page 1 of 1
How To Create a New View?
You can create a new view based on one or more existing tables by using the CREATE VIEW
statement as shown in the following script:
CREATE VIEW employee_department AS
SELECT e.employee_id, e.first_name, e.last_name, e.email,
e.manager_id, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id;
View created.
SELECT first_name, last_name, department_name
FROM employee_department WHERE manager_id = 101;
FIRST_NAME LAST_NAME DEPARTMENT_NAME
-------------------- ------------------------- ------------------
Nancy Greenberg Finance
Jennifer Whalen Administration
Susan Mavris Human Resources
Hermann Baer Public Relations
Shelley Higgins Accounting
statement as shown in the following script:
CREATE VIEW employee_department AS
SELECT e.employee_id, e.first_name, e.last_name, e.email,
e.manager_id, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id;
View created.
SELECT first_name, last_name, department_name
FROM employee_department WHERE manager_id = 101;
FIRST_NAME LAST_NAME DEPARTMENT_NAME
-------------------- ------------------------- ------------------
Nancy Greenberg Finance
Jennifer Whalen Administration
Susan Mavris Human Resources
Hermann Baer Public Relations
Shelley Higgins Accounting
Similar topics
» What Is a Dynamic Performance View?
» How To Drop an Existing View?
» How To View Existing Locks on the Database?
» How To View All Columns in an Existing Table?
» How To Create a New Table?
» How To Drop an Existing View?
» How To View Existing Locks on the Database?
» How To View All Columns in an Existing Table?
» How To Create a New Table?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Sun Jan 31, 2010 12:35 am by Micheal
» Accessing tables of other users in SQL
Sun Jan 31, 2010 12:34 am by Micheal
» Grouping commands in SQL
Sun Jan 31, 2010 12:32 am by Micheal
» Operations on Result Sets in SQL
Sun Jan 31, 2010 12:31 am by Micheal
» Subqueries in SQL
Sun Jan 31, 2010 12:30 am by Micheal
» Joining Relations in SQL
Sun Jan 31, 2010 12:28 am by Micheal
» Delete comand in SQL
Sun Jan 31, 2010 12:27 am by Micheal
» Update command in SQL
Sun Jan 31, 2010 12:26 am by Micheal
» Insert command in SQL
Sun Jan 31, 2010 12:23 am by Micheal