How to quota a CDB only tablespace to a CDB user?
-
14-03-2021 - |
Pregunta
- I can create a CDB tablespace like this: (all using:
sqlplus / as sysdba
)
-- create unique table space for admin
CREATE TABLESPACE admints DATAFILE '/path/to/admints.dbf' SIZE 20M AUTOEXTEND ON;
- I can create a CDB user with a default tablespace "system" since all PDBs have a "system" tablespace:
-- create admin user on CDB (the defaut tablespace is "system")
CREATE USER C##admin IDENTIFIED BY P@ssw0rd DEFAULT TABLESPACE system QUOTA UNLIMITED ON system ACCOUNT UNLOCK;
- I can't create my user with default tablespace "admints":
CREATE USER C##admin IDENTIFIED BY P@ssw0rd DEFAULT TABLESPACE admints QUOTA UNLIMITED ON admints ACCOUNT UNLOCK
*
ERROR at line1:
ORA-65048: error encountered when processing the current DDL statement in
pluggable database ORCLPDB
ORA-00959: tablespace 'ADMINTS' does not exist
- And I can't give quota to my created user on my created tablespace since it only on the CDB and didn't been created for each PDB. is that correct?
ALTER USER C##admin quota unlimited on admints unlimited
*
ERROR at line1:
ORA-65048: error encountered when processing the current DDL statement in
pluggable database ORCLPDB
ORA-00959: tablespace 'ADMINTS' does not exist
- The "admits" tablespace has been created once only for the CDB, not for each PDB.
- I want to create the C##admin user's tables on the "admits" tablespace on the CDB and have an unlimited quota on it.
- I want the C#admin to have at least read access on all PDBs, so I can't unload them.
- Is it possible?
Solución
All containers have a default tablespace:
SQL> select p1.name, p2.property_name, p2.property_value
from v$containers p1 join cdb_properties p2 on (p1.con_id = p2.con_id)
where property_name = 'DEFAULT_PERMANENT_TABLESPACE' order by 1;
NAME PROPERTY_NAME PROPERTY_VALUE
---------- ------------------------------ --------------------
CDB$ROOT DEFAULT_PERMANENT_TABLESPACE USERS
PDB1 DEFAULT_PERMANENT_TABLESPACE USERS
PDB2 DEFAULT_PERMANENT_TABLESPACE SALES
Create the user without specifying anything:
SQL> create user c##myadmin identified by password;
User created.
SQL> select p1.name, u.default_tablespace
from v$containers p1 join cdb_users u on (p1.con_id = u.con_id)
where username = 'C##MYADMIN' order by 1;
NAME DEFAULT_TABLESPACE
---------- ------------------------------
CDB$ROOT USERS
PDB1 USERS
PDB2 SALES
Then alter the user in the root container:
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter user c##myadmin default tablespace admints quota unlimited on admints container=current;
User altered.
SQL> select p1.name, u.default_tablespace
from v$containers p1 join cdb_users u on (p1.con_id = u.con_id)
where username = 'C##MYADMIN' order by 1;
NAME DEFAULT_TABLESPACE
---------- ------------------------------
CDB$ROOT ADMINTS
PDB1 USERS
PDB2 SALES
SQL> select c.name, q.tablespace_name, q.max_bytes
from v$containers c join cdb_ts_quotas q on (c.con_id = q.con_id)
where q.username = 'C##MYADMIN';
NAME TABLESPACE_NAME MAX_BYTES
---------- ------------------------------ ----------
CDB$ROOT ADMINTS -1
Licenciado bajo: CC-BY-SA con atribución
No afiliado a dba.stackexchange