Oracle

將表移動到新表空間需要臨時空間或任何類型的成癮空間?(甲骨文 11g)

  • March 27, 2019

我一直在嘗試在 oracle 文件上搜尋此資訊,但他們只是不談論它。

我需要將大約 2TB 的不同表從 3 個不同的表空間移動到一個新的表空間(加密的表空間)。我需要有臨時空間嗎(2TB)?

移動表不使用臨時表空間。

SQL> show parameter target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
archive_lag_target                   integer     0
db_flashback_retention_target        integer     1440
fast_start_io_target                 integer     0
fast_start_mttr_target               integer     0
memory_max_target                    big integer 0
memory_target                        big integer 0
parallel_servers_target              integer     64
pga_aggregate_target                 big integer 256M
sga_target                           big integer 1G

SQL> select bytes/1024/1024 as bytes_mb, tablespace_name from user_segments where segment_name = 'SALES2';

 BYTES_MB TABLESPACE_NAME
---------- ------------------------------
     2240 EXAMPLE2

SQL> select file_id from dba_temp_files;

  FILE_ID
----------
        1

SQL> alter database tempfile 1 drop;

Database altered.

SQL> select file_id from dba_temp_files;

no rows selected

SQL> select sys_context('userenv', 'sid') from dual;

SYS_CONTEXT('USERENV','SID')
--------------------------------------------------------------------------------
191

SQL> select serial# from v$session where sid = 191;

  SERIAL#
----------
      415

SQL> alter table sales2 move tablespace example3;

Table altered.

SQL> select bytes/1024/1024 as bytes_mb, tablespace_name from user_segments where segment_name = 'SALES2';

 BYTES_MB TABLESPACE_NAME
---------- ------------------------------
     2240 EXAMPLE3

SQL> select max(temp_space_allocated), count(*) from v$active_session_history where session_id = 191 and session_serial# = 415;

MAX(TEMP_SPACE_ALLOCATED)   COUNT(*)
------------------------- ----------
                       0         33

你不需要2TB的臨時空間,現在數據庫在排序或查詢3個表時使用的臨時空間就足夠了。

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