CTAS建表时报错ORA-65114

ctas,时报,ora · 浏览次数 : 49

小编点评

## Root Cause Analysis and Solution **Problem:** The SQL statement failed due to exceeding the available space in the database container. **Key Points:** * The maximum allowed space for the container is set to 2147483648 bytes. * The database attempted to create a datafile with a size exceeding 10GB, exceeding the allowed space. * This is caused by the following constraints: * `MAX_PDB_STORAGE` in the `cdb_properties` table limits the total size to 2G. * `FILE_NAME_CONVERT` specifies a path prefix for the data file, which needs to be within the allowed size. **Solution:** 1. **Increase the `MAX_PDB_STORAGE` value:** * Use the `ALTER PLUGGABLE DATABASE` statement with the `MAXSIZE` parameter set to a higher value (5G in this case). * This allows the database to accommodate the larger data file. 2. **Review the file naming convention:** * Ensure the data file is placed within the allowed path prefix specified by `FILE_NAME_CONVERT`. * This avoids exceeding the size limitations imposed by the database. **Additional Notes:** * Remember to restart the Oracle database after making changes to the `cdb_properties` or `pdbs` file. * Adjust the `MAXSIZE` value based on your specific requirements.

正文

环境: Oracle 19.16 多租户架构

1.问题现象:

SQL> 
create table T1 as select * from v$active_session_history
                                 *
ERROR at line 1:
ORA-65114: space usage in container is too high

2.查看错误信息:

SQL> !oerr ora 65114
65114, 00000, "space usage in container is too high"
// *Cause:  Space usage in the current container exceeded the value of
//          MAX_PDB_STORAGE for the container.
// *Action: Specify a higher value for MAX_PDB_STORAGE using the ALTER
//          PLUGGABLE DATABASE statement.
//

3.查询MAX_PDB_STORAGE设置

需要注意这里所说的MAX_PDB_STORAGE并不是一个参数,若直接show parameter MAX_PDB_STORAGE是查不到的。
而是一个数据库的属性,使用这样的查询方法:

--PDB中查询:
select property_value from database_properties where property_name = 'MAX_PDB_STORAGE';
--CDB中查询:
select property_name, property_value, description, con_id from cdb_properties where property_name = 'MAX_PDB_STORAGE';

我这里在CDB中查询:

SQL> col PROPERTY_NAME for a22
SQL> col PROPERTY_VALUE for a22
SQL> col DESCRIPTION for a66
SQL> select property_name, property_value, description, con_id from cdb_properties where property_name = 'MAX_PDB_STORAGE';

PROPERTY_NAME          PROPERTY_VALUE         DESCRIPTION                                                            CON_ID
---------------------- ---------------------- ------------------------------------------------------------------ ----------
MAX_PDB_STORAGE        2147483648             Maximum Space Usage of Datafiles and Local Tempfiles in Container           6
MAX_PDB_STORAGE        UNLIMITED              Maximum Space Usage of Datafiles and Local Tempfiles in Container           3
MAX_PDB_STORAGE        UNLIMITED              Maximum Space Usage of Datafiles and Local Tempfiles in Container           4

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         6 AWR                            READ WRITE NO

正好对应AWR这个PDB,MAX_PDB_STORAGE有限制2147483648大小。
进入AWR这个PDB,验证查询:

SQL> alter session set container=awr;

Session altered.

SQL> select sum(bytes/1024/1024/1024) from dba_data_files;

SUM(BYTES/1024/1024/1024)
-------------------------
               2.08984375

SQL> select sum(bytes) from dba_data_files;

SUM(BYTES)
----------
2243952640

的确已经达到这个限制,所以不成功是正常的。

4.找出根因

咋会有这个限制呢?翻出之前建立这个PDB的创建语句,就会发现根因:

CREATE PLUGGABLE DATABASE awr
  ADMIN USER awr IDENTIFIED BY awr
  ROLES = (dba)
  DEFAULT TABLESPACE tbs_awr
    DATAFILE '/flash/oradata/DEMO/awr/awr01.dbf' SIZE 250M AUTOEXTEND ON maxsize 10G	<--- 这里限制该数据文件上限大小10G
  FILE_NAME_CONVERT = ('/flash/oradata/DEMO/pdbseed/',
                       '/flash/oradata/DEMO/awr/')
  STORAGE (MAXSIZE 2G)						<--- 这里限制了总大小2G,额。。
  PATH_PREFIX = '/flash/oradata/DEMO/awr/';

5.解决问题

知道原因了,解决就很简单了,直接修正下,因为我测试环境空间有限,所以暂时就在此基础上先增加3G,也就是修改设置为5G。

ALTER PLUGGABLE DATABASE STORAGE (MAXSIZE 5G);

再次执行CTAS语句,不再报错,成功创建。

与CTAS建表时报错ORA-65114相似的内容: