表空间'USERS'没有特权

时间:2015-01-14 10:16:59

标签: database oracle privileges tablespace

我有很多表可以插入行,但是我只为一个表得到了这个错误;

Error starting at line 1 in command:
INSERT INTO ERRORLOG (MESSAGE) VALUES ('test')
Error report:
SQL Error: ORA-01950: no privileges on tablespace 'USERS'
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.

我不是oracle的专家,但正如我从错误信息中理解的那样; 'USERS'表空间已满,我的用户没有权限扩展表空间,但其他表'(我可以插入)表空间'是相同的.. 这里有一个用于可插入表的sql和得到错误的表;

没问题;

  CREATE TABLE "MYUSER"."HEADSHIP" 
   (    "ID" NUMBER NOT NULL ENABLE, 
    "DESCRIPTION" VARCHAR2(255 BYTE), 
    "ISDELETED" VARCHAR2(1 BYTE) DEFAULT 0 NOT NULL ENABLE, 
     CONSTRAINT "HEADSHIP_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE, 
     CONSTRAINT "HEADSHIP_UI" UNIQUE ("DESCRIPTION")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;


  CREATE OR REPLACE TRIGGER "MYUSER"."HEADSHIP_TRG" BEFORE INSERT ON HEADSHIP 
FOR EACH ROW 
BEGIN
  <<COLUMN_SEQUENCES>>
  BEGIN
    IF :NEW.ID IS NULL THEN
      SELECT HEADSHIP_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
    END IF;
  END COLUMN_SEQUENCES;
END;
/
ALTER TRIGGER "MYUSER"."HEADSHIP_TRG" ENABLE;

获取错误;

CREATE TABLE "MYUSER"."ERRORLOG" 
   (    "ID" NUMBER NOT NULL ENABLE, 
    "MESSAGE" VARCHAR2(2048 BYTE), 
    "STACKTRACE" VARCHAR2(2048 BYTE), 
    "XDATE" DATE, 
    "USERLDAPNAME" VARCHAR2(127 BYTE), 
    "QUERY" VARCHAR2(2048 BYTE), 
     CONSTRAINT "ERRORLOG_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;


  CREATE OR REPLACE TRIGGER "MYUSER"."ERRORLOG_TRG" BEFORE INSERT ON ERRORLOG 
FOR EACH ROW 
BEGIN
  <<COLUMN_SEQUENCES>>
  BEGIN
    IF :NEW.ID IS NULL THEN
      SELECT ERRORLOG_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
    END IF;
  END COLUMN_SEQUENCES;
END;
/
ALTER TRIGGER "MYUSER"."ERRORLOG_TRG" ENABLE;

2 个答案:

答案 0 :(得分:9)

您的用户MYUSER没有任何权限可以将数据插入USERS表空间。您必须为用户提供插入USERS表空间的权限或配额。您可以通过几种不同的方式完成此任务:

  1. 您可以向用户提供,例如USERS表空间中MYUSER无限制配额:

    ALTER USER MYUSER QUOTA UNLIMITED ON USERS;
    
  2. 您还可以定义允许用户在表空间上分配的空间最大值:

    ALTER USER MYUSER QUOTA 100M ON USERS;
    
  3. 您还可以为用户提供UNLIMITED TABLESPACE系统权限,这意味着他对数据库中的任何表空间都有无限制的配额:

    GRANT UNLIMITED TABLESPACE TO MYUSER;
    
  4. 要获得有关Oracle数据库用户的资源管理的更多信息,请查看Oracle Database Documentation

答案 1 :(得分:2)

如果您的用户在创建表时指定了RESOURCEUNLIMITED TABLESPACE角色,则可以获得此效果;但这已被撤销,现在该表正试图分配一个新的范围。您的用户没有为表空间显式设置配额;如果有,那么你就会看到&#34; ORA-01536:超出了桌面空间的空间配额&#39; USERS&#39;&#34;相反,即使随后通过将配额设置为零来删除配额。

要查看效果:

-- grant unlimited tablespace to user;

create table t42 (id number) tablespace users;

Table t42 created.

insert into t42
select level as id
from dual
connect by level < 1000;

1,999 rows inserted.

select extents from user_segments where segment_name = 'T42';

   EXTENTS
----------
         1 

-- revoke unlimited tablespace from user;

此时我仍然可以插入数据:

insert into t42 values (2000);

1 rows inserted.

但是如果我插入足够的行以要求分配第二个范围,则会因此错误而失败:

insert into t42
select level + 2000 as id
from dual
connect by level < 2000;

Error report -
SQL Error: ORA-01950: no privileges on tablespace 'USERS'
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.

据推测,您的DBA一直在做一些特权管理,可能会撤销RESOURCE,因为它被弃用了。

正如评论中所提到的,您的DBA需要在表空间上为您提供一些空间,具有特定大小或(与之前的匹配)无限制:

grant quota unlimited on users to myuser;