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.
Related
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;
I am using oracle 12c and I'm having a little trouble trying to attribute tablespace to a user.
Here is the error I got when processing the current DDL statement in pluggable database ORAPDB1:
the tablespace 'INTERVENTION_TBS' does no exist
Note that the tablespace was created successfully. So could someone suggest a solution please?
For more details I used this syntax query
CREATE USER c##DBAINTERVENTION
Identified by interventiondb
Default Tablespace INTERVENTION_TBS
Temporary Tablespace INTERVENTION_TempTBS;
run the following statements:
alter session set "_ORACLE_SCRIPT"=TRUE;
ALTER USER [username] IDENTIFIED BY [password];
You are trying to create a common user which will have access to all the PDBs in a CDB. As the user has access to all PDBs it can also create an object on those PDBs hence we need tablespace to create the objects. This is the reason why you need to have the tablespace specified in the CREATE USER command on all PDBs.
Please verify that you the INTERVENTION_TBS tablespace exists on all PDBs using the following query.
select cp.pdb_name
from cdb_pdbs cp join v$tablespace tb on(cp.con_id=tb.con_id)
where tb.name='INTERVENTION_TBS';
This query list all the PDBs which has the tablespace. If this tablespace doesn't exist on one of your PDBs then create one.
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).
Unfortunately one UNDO data file was misplaced in wrong location when I was adding space. I want to move that file to correct location. As it is Production database, I don't want to disturb the ongoing transactions. Can I offline that particular undo data file, while moving... will Database work normally with zero data loss?
Version Of Oracle DB: 11.2.0.4.0
can any one suggest?
During database running and in 24/7 environment, you should need to create new undo tablespace with new location of undo datafile. After creating this newer tablespace, you can switch older to newer undo tablespace online without affecting any ongoing transactions.
Following example shows how to achieve your goal. Using this trick, you can avoid data loss.
SQL>create undo tablespace undotbs2 datafile '/yournewlocation/undotbs02.dbf' size 1000m;
Now set new undo tablespace as default undo tablespace using following command as SYSDBA in SQLPLUS
SQL> alter system set undo_tablespace= undotbs2 ;
After finishing above task you can drop old undotbs tablespace from database using following command.
SQL> drop tablespace undotbs including contents;
I would consider creating the undo tablespace as a BIGFILE datafile:
CREATE BIGFILE UNDO TABLESPACE UNDOTBS02
DATAFILE '/yournewlocation/UNDOTBS02.dbf'
SIZE 100M AUTOEXTEND ON NEXT 100M
MAXSIZE 500G; --or whatever size you consider sufficient for your DB
I would also alter the system with a scope of BOTH, to make sure the change is made in both memory and spfile:
ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS02 SCOPE=BOTH;
Then, provided all active transactions and the UNDO_RETENTION period (if any) are done, you'll be able to drop the tablespace as described by doc123.
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