創建測試表空間
create tablespace tablespacereadonly datafile '/u02/oradata/orcl/tablespacereadonly01.dbf' size 1m autoextend on next 1m maxsize unlimited;
創建測試用戶
create user ureadonly identified by "123456" default tablespace tablespacereadonly;
給測試用戶授權
grant connect,resource to uoffline;創建測試表
插入測試數據
insert into t01(id,name) values (2,'b');
commit;select * from t01;
將表空間置爲只讀
alter tablespace tablespacereadonly read only;select * from t01;
--insert into...
--不可修改
insert into t01(id,name) values (3,'c');--delete from...
delete from t01 where id=1;
--create table...
--創建表空間時需要分配空間,表空間爲只讀,故不允許操作
create table t02(id integer,name varchar2(10));
--alter table...rename to...
--alter table...rename to...只刪除數據字典的相關信息(表並沒有實際刪除),而數據字典存在在system表空間中,system表空間未置爲只讀
--可修改
alter table t02 rename to t01;--alter table...add...
--alter table...add...只修改數據字典的相關信息,而數據字典存在在system表空間中,system表空間未置爲只讀
--可修改
alter table t01 add age integer;--alter table...drop column...不僅修改數據字典的相關信息,同時也將該字段佔用的空間進行釋放,由於表空間爲只讀,故不可操作
--不可修改
alter table t01 drop column age;
--alter table...rename column...to...
--alter table...rename column...to...只修改數據字典的相關信息,而數據字典存在在system表空間中,system表空間未置爲只讀
--可修改
alter table t01 rename column age to ages;--alter table...modify...只修改數據字典的相關信息,而數據字典存在在system表空間中,system表空間未置爲只讀
--可修改
alter table t01 modify name varchar2(20);--drop table...
--可修改
drop table t01;