Oracle

如何將僅 CDB 的表空間配額分配給 CDB 使用者?

  • January 18, 2021
  • 我可以像這樣創建一個 CDB 表空間:(全部使用sqlplus / as sysdba:)
-- create unique table space for admin
CREATE TABLESPACE admints DATAFILE '/path/to/admints.dbf' SIZE 20M AUTOEXTEND ON;
  • 我可以創建一個具有預設表空間“系統”的 CDB 使用者,因為所有 PDB 都有一個“系統”表空間:
-- 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;
  • 我無法使用預設表空間“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
  • 而且我不能在我創建的表空間上為我創建的使用者提供配額,因為它只在 CDB 上並且不是為每個 PDB 創建的。那是對的嗎?
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
  • “admits”表空間只為 CDB 創建一次,而不是為每個 PDB 創建一次。
  • 我想在 CDB 的“admits”表空間上創建 C##admin 使用者的表,並在其上擁有無限配額。
  • 我希望 C#admin 至少對所有 PDB 具有讀取權限,因此我無法解除安裝它們。
  • 是否可以?

所有容器都有一個預設表空間:

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

創建使用者而不指定任何內容:

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

然後更改根容器中的使用者:

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

引用自:https://dba.stackexchange.com/questions/283492