Monday, July 14, 2014

Read Only Table In Oracle 11g Database

In oracle 11g database allowed read only table where INSERT/UPDATE are not allowed, Only select statement allowed in this types of table.


SQL> CONN TEST/TEST;
Connected.
SQL> CREATE TABLE READ_ONLY(ID NUMBER, NAME VARCHAR2(300));

Table created.

SQL> INSERT INTO READ_ONLY VALUES(10, 'RAJIB');

1 row created.

SQL> COMMIT;

Commit complete.

SQL> SET LINE 2000;
SQL> /

        ID NAME
---------- -----------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
        10 RAJIB

SQL> ALTER TABLE READ_ONLY READ ONLY;

Table altered.

SQL> INSERT INTO READ_ONLY VALUES(12, 'TEST USER');
INSERT INTO READ_ONLY VALUES(12, 'TEST USER')
            *
ERROR at line 1:
ORA-12081: update operation not allowed on table "TEST"."READ_ONLY"


SQL> SELECT * FROM READ_ONLY;

        ID NAME
---------- -----------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
        10 RAJIB

SQL> UPDATE READ_ONLY
  2  SET ID=100;
UPDATE READ_ONLY
       *
ERROR at line 1:
ORA-12081: update operation not allowed on table "TEST"."READ_ONLY"

SQL>

No comments:

Post a Comment