结论先行:
1,此表的创建用户权限无问题,表上有其他用户创建的索引
2,报错时,这个索引的创建用户在表空间上无权限或配额
3,dba权限的回收,会导致UNLIMITED TABLESPACE系统权限被回收
4,处理方法:给索引创建用户授予权限或配额
grant UNLIMITED TABLESPACE to username;
或
alter user username quota unlimited on tablespace_name;
报错官方解释:
Oracle@oel:/home/oracle>oerr ora 01950
01950, 00000, "no privileges on tablespace '%s'"
// *Cause: User does not have privileges to allocate an extent in the
// specified tablespace.
// *Action: Grant the user the appropriate system privileges or grant the user
// space resource on the tablespace.
测试过程如下:
1,创建测试表
TEST@regan1> create table test tablespace test as select * from sys.dba_objects;
Table created.
TEST@regan1> create index idx_test_01 on test(OBJECT_NAME) tablespace test;
Index created.
TABLESPACE_NAME TABLESPACE_T SUM_SPACE(M) SUM_BLOCKS USED_SPACE(M) USED_RATE(%) FREE_SPACE(M)
-------------------- ------------ ------------ ---------- ------------- ------------ -------------
USERS PERMANENT 1399 179040 1330 95.05 69
TEST PERMANENT 200 25600 4 1.94 196
2,创建测试用户
SYS@regan1> create user test02 identified by test;
User created.
SYS@regan1> select username,default_tablespace from dba_users where username like 'TEST%';
USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
TEST TEST
TEST02 USERS
SYS@regan1> grant connect to test02;
Grant succeeded.
SYS@regan1> grant resource to test02;
Grant succeeded.
3,创建测试用户下索引
TEST@regan1> grant index on test to test02;
Grant succeeded.
SYS@regan1> grant unlimited tablespace to test02;
Grant succeeded.
TEST02@regan1> create index idx_test_02 on test.test(OBJECT_ID) tablespace test;
Index created.
TEST@regan1> select index_name,tablespace_name,status from dba_indexes where table_name='TEST';
INDEX_NAME TABLESPACE_NAME STATUS
------------------------------ -------------------- --------
IDX_TEST_01 TEST VALID
IDX_TEST_02 TEST VALID
4,查看索引extent
TEST@regan1> select OWNER,EXTENT_ID,BYTES/1024 from dba_extents where SEGMENT_NAME='IDX_TEST_02';
OWNER EXTENT_ID BYTES/1024
------------------------------ ---------- ----------
TEST02 0 64
TEST02 1 64
TEST02 2 64
TEST02 3 64
TEST02 4 64
5,插入测试
TEST@regan1> insert into test select * from test;
14082 rows created.
TEST@regan1> COMMIT;
Commit complete.
TEST@regan1> select OWNER,EXTENT_ID,BYTES/1024 from dba_extents where SEGMENT_NAME='IDX_TEST_02';
OWNER EXTENT_ID BYTES/1024
------------------------------ ---------- ----------
TEST02 0 64
TEST02 1 64
TEST02 2 64
TEST02 3 64
TEST02 4 64
TEST02 5 64
TEST02 6 64
TEST02 7 64
TEST02 8 64
9 rows selected.
6,授予dba权限并回收
SYS@regan1> select * from dba_sys_privs where grantee='TEST02';