How to Create SQL View
Introduce to SQL View
SQL View is a virtual table which is used to encapsulate a complex queries. After creating SQL view, you can treat a view as a table and
manipulate data on it with only some restrictions. When the data in table changes, the data in view which is dependent on table changes also.
View does not occupied the physical space as table does. The syntax of creating view as follows:
CREATE VIEW SALARY_REC
AS
SELECT e.last_name,
e.salary,
d.department_name AS department_name
FROM employees e
INNER JOIN departments d ON e.department_id = d.department_id
Output:
SELECT * FROM SALARY_REC
OConnell 2860 Shipping
Grant 2860 Shipping
Whalen 4840 Administration
Hartstein 14300 Marketing
Fay 6600 Marketing
Mavris 7150 Human Resources
Baer 11000 Public Relations
Higgins 13200 Accounting
Gietz 9130 Accounting
Sullivan 2750 Shipping
Geoni 3080 Shipping
Sarchand 4620 Shipping
Bull 4510 Shipping
Introduce to SQL View
SQL View is a virtual table which is used to encapsulate a complex queries. After creating SQL view, you can treat a view as a table and
manipulate data on it with only some restrictions. When the data in table changes, the data in view which is dependent on table changes also.
View does not occupied the physical space as table does. The syntax of creating view as follows:
CREATE VIEW SALARY_REC
AS
SELECT e.last_name,
e.salary,
d.department_name AS department_name
FROM employees e
INNER JOIN departments d ON e.department_id = d.department_id
Output:
SELECT * FROM SALARY_REC
OConnell 2860 Shipping
Grant 2860 Shipping
Whalen 4840 Administration
Hartstein 14300 Marketing
Fay 6600 Marketing
Mavris 7150 Human Resources
Baer 11000 Public Relations
Higgins 13200 Accounting
Gietz 9130 Accounting
Sullivan 2750 Shipping
Geoni 3080 Shipping
Sarchand 4620 Shipping
Bull 4510 Shipping
0 comments:
Post a Comment
Thank you for your comments we will get back to soon