Oracle 11g 修改表的所屬表空間

2021-09-25 08:16:55 字數 1729 閱讀 2210

應領導要求,需要將部分表的所屬表空間進行更改,目的為了整理使用者。

select tablespace_name,count(*) from dba_tables where owner = '***' group by tablespace_name order by 2;
select * from dba_tables where owner = '***' and tablespace_name = 'users';
select table_name,num_rows from dba_tables where owner = '***' and tablespace_name = 'users' order by 2 desc;
select t.table_name as "表名",

t.num_rows as "錶行數",

nvl(s.partition_name, 0) as "分割槽名",

s.segment_type "段型別",

s.bytes / 1024 / 1024 as "段大小(mb)"

from dba_tables t, dba_segments s

where t.table_name = s.segment_name(+)

and t.owner = '***'

and t.tablespace_name = 'users'

order by s.bytes

desc;

select count(*) from(

select table_name

from dba_tables

where owner = '***'

and table_name not like 't\_%' escape '\'

and table_name not like 'jf\_%' escape '\'

and table_name not like 'payment\_%' escape '\'

and table_name not like 'prom%'

and table_name <> 'customer_buy_his');

select index_name,index_type,table_name,table_owner,table_type,uniqueness,status from dba_indexes where owner = '***' and tablespace_name = 'users';
select 'alter table '||table_name||' move tablespace ylpw;' from dba_tables where tablespace_name = 'users' and owner = '***';
select 'alter index ' ||index_name||' rebuild online;' from dba_indexes where table_owner = 'yl2012' and status <> 'valid';
1、要考慮move後的索引重建問題

2、盡量放在業務低峰期或者夜間進行

3、對於大表考慮重建索引時占用的cpu跟臨時表空間的問題

oracle11g匯出空表

該引數意思是當建立物件 如表 初始時沒有資料,是否立即建立segment。預設是true。這會導致在按使用者匯出時,沒有segment的物件不會匯出。首先執行下面的語句 select alter table table name allocate extent from user tables wh...

oracle11g分割槽表

1按需建立分割槽,可以自動擴充套件分割槽 create table f sales sales amt number,d date date partition by range d date interval numtoyminterval 1,year partition p1 values l...

oracle 11g匯出空表

oracle 11g 用exp命令匯出庫檔案備份時,發現只能匯出來一部分表而且不提示錯誤,之前找不到解決方案只能把沒匯出來的表重新建建立。後來發現是所有的空表都沒有匯出來。於是想好好查查,因為在以前的10g版本中沒有這樣的問題。查資料發現oracle 11g中有個新特性 新增了乙個引數 deferr...