To define an updatable view, a query expression must also meet these requirements:
•
It cannot contain a JOIN, UNION, or EXCEPT clause.
•
It cannot contain a GROUP BY or HAVING clause.
•
It cannot directly contain the keyword DISTINCT.
•
The FROM clause must refer to exactly one table or one updatable view.
•
It cannot contain a WHERE clause that contains a subquery.
•
The select list cannot include expressions or functions or duplicate column names.
Examples of CREATE VIEW
•
This example creates a view on a single table without a view column list:
CREATE VIEW SALES.MYVIEW1 AS
SELECT ordernum, qty_ordered FROM SALES.ODETAIL;
•
This example creates a view with a column list:
CREATE VIEW SALES.MYVIEW2
(v_ordernum, t_partnum) AS
SELECT v.ordernum, t.partnum
FROM SALES.MYVIEW1 v, SALES.ODETAIL t;
•
This example creates a view from two tables by using an INNER JOIN:
CREATE VIEW MYVIEW4
(v_ordernum, v_partnum) AS
SELECT od.ordernum, p.partnum
FROM SALES.ODETAIL OD INNER JOIN SALES.PARTS P
ON od.partnum = p.partnum;
CREATE VIEW Statement
89