Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9263333
  • 博文数量: 1669
  • 博客积分: 16831
  • 博客等级: 上将
  • 技术积分: 12594
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 07:23
个人简介

柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!

文章分类

全部博文(1669)

文章存档

2023年(4)

2022年(1)

2021年(10)

2020年(24)

2019年(4)

2018年(19)

2017年(66)

2016年(60)

2015年(49)

2014年(201)

2013年(221)

2012年(638)

2011年(372)

分类: Oracle

2011-12-13 16:51:16

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这个空间里了

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