Oracle database error "space quota exceeded for tablespace 'USERS'_ " - oracle

I am getting following error while executing script from application :
ORA-30032: the suspended (resumable) statement has timed out_ORA-01536: space quota exceeded for tablespace 'USERS'_

in the first place:
The error you are hitting (ORA-01536) is complaining about the permissions of the user you are logged in.
That user is trying to add data to a table that belongs to a tablespace named USERS.
A tablespace is a logical container that hides the physical storage behind the persistence of a table, and each table is explicitly or implicitly assigned a tablespace upon creation (if not specified, the tablespace is a assigned the "default" tablespace associated to the user when the user was created, often the USERS tablespace).
If you want your user have no restrictions on the amount of data it puts in USERS, run:
ALTER USER <your user> quota unlimited on USERS;
or if you want to limit the quota to, say, 10 MB:
alter user <your user> quota 10M on USERS;
See Managing Users and Resources for more details.
secondly:
If you are just playing around with your database and don't want to have any space restriction (e.g. you are not using a production database), run either of the following:
grant resource to <your user> ;
--or
grant unlimited tablespace to <your user> ;
Note that the above statements must be executed by another user, and that other user must have the power to grant the relevant permissions to others (for instance log in as SYSDBA). If you execute them from your user, or the user has not the proper grants, the statements will fail.
by the way:
ORA-30032 is just sort of a wrapper for your real error, simply indicating that the DB has suspended your session waiting a bit for you to fix the tablespace allocation problem, until a timeout made it give up (see Resumable timeout explained).

Related

Oracle: Can you grant CREATE GLOBAL TEMPORARY TABLE specifically?

Can you grant privilege to allows the creation of a global temporary table ONLY, i.e. without CREATE TABLE?
The background of this stems from security models that don't allow 'CREATE TABLE'... I can't find a reference to any specific privileges.
I can't find a reference to any specific privileges.
Because, as far as I know, there is none. You'll still have to grant CREATE TABLE privilege to a user so he could create TEMPORARY tables.
In order to prevent a user from creating regular tables, and allow him to create only temporary tables you might consider the following:
Grant CREATE TABLE privilege to a user and revoke quota on a specific tablespace.
alter user <<user_name>> quota 0M on <<tablespace>>;
It might be the user's default tablespace or a different one.
In Oracle's versions with no DEFFERED_SEGMENT_CREATION it'll be enough for the user to see space quota exceeded for tablespace when he/she tries to create a regular table.
In Oracle's version with DEFFERED_SEGMENT_CREATION a user will still be able to create regular tables, but will not be able populate them. The second the user tries to execute an INSERT statement the space quota exceeded for tablespace appears.
So you might consider setting deferred_segment_creation parameter to false.
alter system set deferred_segment_creation = false;

How to grant quota on a temporary tablespace to a user

I'm trying to create a user in Oracle 12c with a default temporary tablespace and with a quota for that tablespace.
My statement is:
CREATE USER test_user2
IDENTIFIED BY "pass1234"
DEFAULT TABLESPACE TEMP_WORK_TS
QUOTA 100M ON TEMP_WORK_TS
QUOTA 100M ON TEMP_TEST_01
TEMPORARY TABLESPACE TEMP_TEST_01
PROFILE DEFAULT_PROFILE
ACCOUNT UNLOCK;
But I get error:
ORA-30041: Cannot grant quota on the tablespace
The Oracle documentation shows a quota being assigned for a user's temporary tablespace.
Why does my statement doing the same thing get that error?
That looks like a documentation bug. That example goes back at least to Oracle 9i documentation, so it may predate true temporary tablespaces.
Also from the 12c documentation:
You can assign each user a tablespace quota for any tablespace (except a temporary tablespace).
And the text for ORA-30041 is:
ORA-30041: Cannot grant quota on the tablespace
Cause: User tried to grant quota on an undo or temporary tablespace
Action: Check the tablespace name and reissue the command
It's said that since 10g, but the 9i version only referred to undo tablespaces. The behaviour seems to have changed, and the example just has hasn't been updated to reflect that.
So you can't grant that temporary tablespace quota. Just omit it from the create user statement. A quota only really makes sense for permanent extents anyway, and you don't know how much temporary space the optimiser might need to allocate for queries the user might run.

ORACLE is QUOTA required?

I have a quick question about assigning quotas to users on tablespaces. Does a user require quota in order to select, update and insert data into a table stored in x tablespace? Do I need to grant that user quota on that x tablespace?
Thanks
The schema needs a quota, explicit or unlimited, in order to be able to create objects within that tablespace, such as tables and indexes.
It is the owner of the table who needs the quota, not the user who modifies it by adding rows.

Are tablespaces associated with user accounts?

I have very basic question related to tablespaces.
When I was creating a user, I was asked to assign a default tablespace for this account. So, I assigned a previously created tablespace (TABLESPACE1).
If I create another user and assign a different tablespace (TABLESPACE2) for this user, then will I not be able to see tables created in TABLESPACE1?
If I create a user having access to both tablespaces (TABLESPACE1 and TABLESPACE2)
then for that user, there is another new database, but it is not actually new.
Could somebody help me to understand table space concept here.
Tablespaces are a storage concept only. They don't play a role in what user can see what tables.
You can set a default tablespace for a user, and you can allow them (or not) to create objects in specific tablespaces, but that is unrelated to what tables they have access to.
Table (and object in general) access is managed with grants. Tablespaces are for physical storage. The two are essentially unrelated.

how to execute several ddl words with batch processing

When I deploy my asp.net application,I have to create some tablesapces/users,I use the pqsql,however I want to know is there any way I can create them with batch processing?
For example,I can execute this ddl:
create tablespace TSA.....
Then I can execute:
create user a ... default tablespace TSA...
But when I execute them at the same time:
create tablespace TSA.....
create user a ... default tablespace TSA...
I will get an error.
ANy way?
update
Error is something like this:
ORA-02180: invalid CREATE TABLESPACE words
BTW,I run the sql batches in the sql window of the pl/sql developer.
Now,I just want to know if there is any way I can run a whole ddl sql file?
Suppose this is the content of the init.sql:
create smallfile tablespace "DEV" datafile 'f:\app\administrator\oradata\orcl\dev01.dbf' size 100m autoextend on next 10m maxsize unlimited logging extent management local segment space management auto default nocompress
-- Create the user
create user dev_sa
identified by "000000"
default tablespace DEV
temporary tablespace TEMP;
-- Grant/Revoke role privileges
grant connect to dev_sa;
grant dba to dev_sa;
--create another tablespace
--.....
How to execute it in the batch process model?
If you have the two statements in a file you're running from SQL*Plus, you need to separate the statements with the / character, which also causes each to be executed
create tablespace TSA ...
/
create user a ... default tablespace TSA
/
(That's quite a big 'if', of course as per #APC's comment; but is something that's come up before. As has different ways of running things in SQL Developer, among other things. But really no more than a guess from the minimal info given...)
You have a semi-colon ; missing off the end of your first CREATE TABLE

Resources