批量修改table和index 的表空間

2021-05-23 23:56:11 字數 803 閱讀 2745

由於開發人員把ess 專案下的大部分物件放到user 表空間中,用imp/exp 匯入正式庫後,ess使用者的物件還是在users 表空間中.為了把ess 的物件放到ess 預設的表空間ess中,我按如下幾步操作:

1 找出要修改表空間的物件:

select * from dba_tables  where owner='ess' and tablespace_name = 'users';

select * from dba_indexes where table_owner='ess' and tablespace_name = 'users';

2 . 生成批量修改的sql 語句

select 'alter table ess.' || table_name || ' move tablespace ess;'

from dba_tables where owner='ess' and tablespace_name = 'users';

select 'alter index ess.'||index_name||' rebuild online nologging tablespace ess;'

from dba_indexes

where table_owner='ess' and tablespace_name = 'users'

把生成sql 語句導到 到ess_table.txt和ess_index.txt 檔案中

3. 執行 ess_table.txt 和 ess_index.txt 檔案 sqll 語句 ,就ok

4  檢查users 表空間,看看ess 使用者的物件是不是少了

Oracle批量修改使用者表table的表空間

一 修改使用者表table的表空間 1 修改使用者表table的表空間 alter table 表名 move tablespace 新錶空間名 2 查詢所有使用者表 select from user tables 指令碼 查詢當前使用者的所有的資料表,並把表空間為 eas d hfy standa...

mybatis批量修改和查詢

使用一條sql語句更新 update cust vehicle when id then when id then where id 屬性說明 1.prefix,suffix 表示在trim標籤包裹的部分的前面或者後面新增內容 2.如果同時有prefixoverrides,suffixoverrid...

table類 初步修改

ifndef table hpp define table hpp include include include include connection.hpp namespace sqlpp must this write.or g report error template inline std...