Chinaunix首页 | 论坛 | 博客
  • 博客访问: 967787
  • 博文数量: 584
  • 博客积分: 2293
  • 博客等级: 大尉
  • 技术积分: 3045
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-28 11:15
文章分类

全部博文(584)

文章存档

2012年(532)

2011年(47)

2009年(5)

我的朋友

分类:

2012-03-31 20:49:31

Oracle 批量移动表和索引的表空间
2011-11-25 17:38

Oracle 数据迁移 批量移动表和索引的表空间  

//实验将XX网迁到gdnyw 表空间

su – oracle

sqlplus /nolog

 connect / as sysdba

create tablespace gdnyw datafile'/home/oracle/oradata/EJETDB/gdnyw_d.dbf' size 300M  AUTOEXTENDON NEXT 2M MAXSIZEUNLIMITED default storage (initial 2Mnext 2Mpctincrease 0); 

//之前创建用户

create user gdnyw identified by gdnywserver ;

grant resourceto gdnyw;

grant connectto gdnyw;

grant unlimitedtablespace to gdnyw;  ---grant dba togdnyw; 一般不赋予dba权限

 create tablespace news_tablespace datafile 'F:\oracle\product\10.1.0\oradata\news\news_data.dbf' size 500M    --一般是建用户时指定表空间。

//

授予用户使用表空间的权限:(一般是新建用户是指定表空间,下面是分开建的)

alter user 用户名quota unlimited on 表空间;

alter user 用户名quota *M on 表空间;  

alter user gdnyw quota unlimited on gdnyw;

--查询当前用户下的所有表 (批量移动表

  回到 gdnyw 这个用户:

select 'alter table  '|| table_name ||'  move tablespace gdnyw;'  from user_all_tables;

--2.修改表的索引的空间

alter index INDEX_NAME rebuild tablespace TABLESPACENAME   

--查询当前用户下的所有索引    

select 'alter index '|| index_name ||' rebuild tablespace cjlogistics;' from user_indexes;  

 

----至此将原gdnyw用户的表全部移到gdnyw这个空间里了

阅读(642) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~