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 »
Oracle »
Table »
Views:
- Creating and Using a View
- Creating and Using Simple Views
- Performing an INSERT Using a View
- A View with a CHECK OPTION Constraint
- View with a READ ONLY Constraint
- Getting Information on View Definitions with DESCRIBE command
- Getting Information on View Definitions with user_views view
- Retrieving Information on View Constraints
- Creating and Using Complex Views
- Modifying a View
- Alter the constraints on a view using ALTER VIEW
- Dropping a View
Related: