no privileges on tablespace 'USERS'

Ahmet Serdar Çuhadaroğlu picture Ahmet Serdar Çuhadaroğlu · Jan 14, 2015 · Viewed 38.5k times · Source

i have many tables that i can insert rows, but i get this error only for one table;

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.

i am not expert on oracle but as i understood from the error message; 'USERS' tablespace is full and my user is not have permission to extend the tablespace but other tables' (that i can insert) tablespaces' are same.. here are sql's that one for insertable table and the table that getting error;

no problem for;

  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;

getting error for;

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;

Answer

gvenzl picture gvenzl · Jan 14, 2015

Your user MYUSER doesn't have any privileges to insert data into the USERS tablespace. You have to give the user the right or quota to insert into the USERS tablespace. You can do this in several different ways:

  1. You can give the user, e.g. MYUSER unlimited quota in the USERS tablespace:

    ALTER USER MYUSER QUOTA UNLIMITED ON USERS;
    
  2. You can also define a space maximum that the user is allowed to allocate on the tablespace:

    ALTER USER MYUSER QUOTA 100M ON USERS;
    
  3. You can also give the user the UNLIMITED TABLESPACE system privilege which means he has unlimited quota on any tablespace within the database:

    GRANT UNLIMITED TABLESPACE TO MYUSER;
    

To get more information around resource management for Oracle Database users have a look at the Oracle Database Documentation.