OCP-1Z0-051 第2題 檢視的WITH CHECK OPTION選項
阿新 • • 發佈:2019-01-06
SQL> CREATE VIEW v4
2 AS SELECT prod_id, cust_id, SUM(quantity_sold) FROM SALES
3 WHERE time_id <= SYSDATE - 2*365
4 GROUP BY prod_id, cust_id
5 WITH CHECK OPTION;
AS SELECT prod_id, cust_id, SUM(quantity_sold) FROM SALES
*
ERROR at line 2:
ORA-00998: must name this expression with a column alias
--將別名補上後,檢視可以建立成功
SQL> CREATE VIEW v4
2 AS SELECT prod_id, cust_id, SUM(quantity_sold) squ FROM SALES
3 WHERE time_id <= SYSDATE - 2*365
4 GROUP BY prod_id, cust_id
5 WITH CHECK OPTION;
View created.
SQL> insert into v4 values(1,2,10);
insert into v4 values(1,2,10)
*
ERROR at line 1:
ORA-01733: virtual column not allowed here
2 AS SELECT prod_id, cust_id, SUM(quantity_sold) FROM SALES
3 WHERE time_id <= SYSDATE - 2*365
4 GROUP BY prod_id, cust_id
5 WITH CHECK OPTION;
AS SELECT prod_id, cust_id, SUM(quantity_sold) FROM SALES
*
ERROR at line 2:
ORA-00998: must name this expression with a column alias
--將別名補上後,檢視可以建立成功
SQL> CREATE VIEW v4
2 AS SELECT prod_id, cust_id, SUM(quantity_sold) squ FROM SALES
3 WHERE time_id <= SYSDATE - 2*365
4 GROUP BY prod_id, cust_id
5 WITH CHECK OPTION;
View created.
SQL> insert into v4 values(1,2,10);
insert into v4 values(1,2,10)
*
ERROR at line 1:
ORA-01733: virtual column not allowed here