View with a READ ONLY Constraint

You can make a view read-only by adding a READ ONLY constraint.

 
CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
                  ENAME VARCHAR2(10),
                  JOB VARCHAR2(9),
                  SAL NUMBER(7, 2),
                  DEPTNO NUMBER(2));
                  
SQL> CREATE VIEW emp_view AS
  2  SELECT *
  3  FROM emp
  4  WHERE sal < 1500
  5  WITH READ ONLY CONSTRAINT emp_read_only;

View created.

SQL>

The database returns an error because the view is read-only and doesn't allow DML statements:


SQL> INSERT INTO emp_view (EMPNO) VALUES (1);
INSERT INTO emp_view (EMPNO) VALUES (1)
                      *
ERROR at line 1:
ORA-01733: virtual column not allowed here


SQL>
Home »
Oracle »
Table » 

Views:
  1. Creating and Using a View
  2. Creating and Using Simple Views
  3. Performing an INSERT Using a View
  4. A View with a CHECK OPTION Constraint
  5. View with a READ ONLY Constraint
  6. Getting Information on View Definitions with DESCRIBE command
  7. Getting Information on View Definitions with user_views view
  8. Retrieving Information on View Constraints
  9. Creating and Using Complex Views
  10. Modifying a View
  11. Alter the constraints on a view using ALTER VIEW
  12. Dropping a View
Related: