Restriction in a view definition
The ORDER BY clause is not allowed in a view definition.
Example views
This view exposes only some of the columns of emp table:
CREATE VIEW emp_info AS SELECT empno, ename FROM emp;
This view exposes derived columns:
CREATE VIEW emp_payroll(empno, total_pay) AS SELECT empno, sal+bonus FROM emp;
CREATE VIEW dept_info(deptno, emp_count) AS SELECT deptno, COUNT(*)
FROM emp GROUP BY deptno;
This view exposes a restricted result set of the base table:
CREATE VIEW emp_high_pay(empno, sal) AS SELECT emp, sal FROM emp
WHERE sal > 100000
This view hides data complexity by exposing the result of a JOIN query:
CREATE VIEW emp_full_info AS (e.empno, d.deptno, d.deptname FROM emp e, dept d WHERE e.deptno = d.deptno;