Read-Only Tables in Oracle 11g (practic test)


SQL> create table test (id number ,name varchar2(12));
Table created.
SQL> insert into test values (1,'ramil');
1 row created.
SQL> insert into test values (2,'rashad');
1 row created.
SQL> insert into test values (3,'amil');
1 row created.
SQL> insert into test values (4,'eldar');
1 row created.
SQL> commit ;
 Commit complete.
SQL> select * from test ;
 ID NAME
---------- ------------
 1 ramil
 2 rashad
 3 amil
 4 eldar
SQL> select table_name,status,read_only from user_tables where table_name='test';
TABLE_NAME STATUS REA
------------------ ----------- -------
test VALID NO
Now placing the table "test" in read only mode .
SQL> alter table test read only;
Table altered.
SQL> insert into test values (5,'sunny');
insert into test values (5,'sunny')
 *
ERROR at line 1:
ORA-12081: update operation not allowed on table "HR"."test"
SQL> delete from test;
delete from test
 *
ERROR at line 1:
ORA-12081: update operation not allowed on table "HR"."test"
SQL> truncate table test;
truncate table test
 *
ERROR at line 1:
ORA-12081: update operation not allowed on table "HR"."test"
Now bringing the table "test" in read write mode .
SQL> alter table test read write;
Table altered.
SQL> insert into test values (5,'sunny');
1 row created.
SQL> commit ;
Commit complete.
SQL> select * from test;
ID NAME
---------- ------------
 1 ramil
 2 rashad
 3 amil
 4 eldar
 5 sunny
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: