您应该始终先咨询Oracle documentation。你要求的是一个简单的single-SQL-command-involving action。您错过的关键知识是您不要更改表空间,alter a datafile。
概念证明
首先,我将只查询我的example 表空间的块大小,因为我将使用该值来证明我的数据文件已正确更改。
SQL> select tablespace_name, block_size
SQL> from dba_tablespaces
SQL> where tablespace_name = 'EXAMPLE';
TABLESPACE_NAME BLOCK_SIZE
------------------------------ ----------
EXAMPLE 8192
好的,tbs 使用 8KB 的块大小。
现在,我的example 数据文件是什么样的?
SQL> select file_name, file_id, tablespace_name, autoextensible, increment_by * &example_tbs_block_size_b / 1048576 as increment_by_mbytes
SQL> from dba_data_files
SQL> where tablespace_name = 'EXAMPLE';
FILE_NAME FILE_ID TABLESPACE_NAME AUTOEXTENSIBLE INCREMENT_BY_MBYTES
---------------------------------- ---------- --------------- -------------- -------------------
D:\ORA\MY_CDB\MY_PDB\EXAMPLE01.DBF 10 EXAMPLE YES 1
好的,我只看到一个自动扩展为 1MB 的数据文件。
现在修改数据文件...
SQL> alter database datafile 10 autoextend on next &target_autoextend maxsize unlimited;
Database altered
并再次检查 tbs 数据文件
SQL> select file_name, file_id, tablespace_name, autoextensible, increment_by * &example_tbs_block_size_b / 1048576 as increment_by_mbytes
SQL> from dba_data_files
SQL> where tablespace_name = 'EXAMPLE';
FILE_NAME FILE_ID TABLESPACE_NAME AUTOEXTENSIBLE INCREMENT_BY_MBYTES
---------------------------------- ---------- --------------- -------------- -------------------
D:\ORA\MY_CDB\MY_PDB\EXAMPLE01.DBF 10 EXAMPLE YES 8
而且,瞧,我有一个 8MB 的自动扩展。