我用到是最新版Oracle19c 測試過程如下
1、創建臨時表空間
create temporary tablespace ekp15temp tempfile 'D:\oracledbms\ekp15temp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
2、創建表空間
create tablespace ekp15tablespace logging datafile 'D:\oracledbms\ekp15.dbf' size 50m autoextend on next 50m maxsize 20480m
3、創建用戶,並給默認表空間
create user ekp15 identified by password default tablespace ekp15tablespace temporary tablespace ekp15temp;
4、給用戶授權
grant connect,resource,dba to ekp15;
5、用ekp15賬戶登錄,並創建表,新增數據,查詢數據
create table t1
(
id varchar2(50) primary key ,
name char(200) not null
);
insert into t1 values ('11','張三');
select * from t1;
能查詢到一條數據,如下圖
6、創建ekp152用戶,使用同一個表空間
create user ekp152 identified by password default tablespace ekp15tablespace temporary tablespace ekp15temp;
7、授權152
grant connect,resource,dba to ekp152;
8、使用ekp152登錄,查詢表t1 發現表t1並不存在(證明ekp152用戶,看不到ekp15用戶的表)
9、查詢表空間下面所有的表,發現t1存在,只是在ekp15這個用戶下面,(再次說明表是在用戶下面,即使同一個表空間也互相看不到)。
select * from all_tables where TABLESPACE_NAME = 'EKP15TABLESPACE'
10、用ekp152用戶,創建t1表,並新增數據,再分別用ekp15和ekp152查詢t1表,
create table t1
(
id varchar2(50) primary key ,
name char(200) not null
);
insert into t1 values ('11','李四');
執行下面3條sql,也可以驗證
select * from all_tables where TABLESPACE_NAME = 'EKP15TABLESPACE';
select * from ekp152.t1;
select * from ekp15.t1;
11、接來下級聯刪除用戶ekp152 試試看,有沒有影響到用戶ekp15的數據
DROP USER ekp152 CASCADE;
再次用ekp15 查詢下t1表,發現還在
再次查詢表空間所有的表,發現只有ekp15名下的一張t1表了
12、總結Oracle 不同用戶,即使共用一個表空間,數據也是互不影響,相互獨立