oracle把表移到另一个表空间,将表迁移至其他表空间
实验环境:REDHAT 5.5 X64系统+ORACLE10.2.0.4
实验要求:将表迁移至其他表空间
实验过程
建立源表空间及用户
create tablespace test1 datafile '/home/oracle/oradata/orcl/test101.dat'
size 100m;
create tablespace test2 datafile '/home/oracle/oradata/orcl/test102.dat'
size 100m;
create user test identified
by test default tablespace test1 temporary tablespace temp;
grant
resource,connect,dba to test;
create table test.testtp
as (select * from dba_object_tables);
create table
test.testtp1 as (select * from dba_object_tables);
create table
test.testtp2 as (select * from dba_object_tables);
create table
test.testtp3 as (select * from dba_object_tables);
conn test/test
create index
testtpi on ttesttp(table_name) tablespace test1;
create index
testtp1i on testtp1(table_name) tablespace test1;
create index
testtp2i on testtp2(table_name) tablespace test1;
create index
testtp3i on testtp3(table_name) tablespace test1;
1.查询当前表空间所包含表
select
table_name ,tablespace_name from dba_tables where tablespace_name = 'TEST1';
2.查询当前用户默认表空间
select
username,default_tablespace from dba_users where username = 'TEST';
3.查询TEST用户下的需要表分析的表并生成表分析语句
注:可能出现回车符号,去掉使得语句为一行,即可执行
SQL> select
'exec dbms_stats.gather_table_stats(ownname=> '|| '''' || owner || ''''||
',tabname=>' ||''''|| table_name ||
''''||',cascade=>true);' from
all_all_tables where owner in ('TEST');
'EXECDBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'||''''||OWNER||''''||',TABNAME=>'||
--------------------------------------------------------------------------------
exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP3',cascade=>true);
exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP2',cascade=>true);
exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP1',cascade=>true);
exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP',cascade=>true);
'EXECDBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'||''''||OWNER||''''||',TABNAME=>'||
SQL> exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP3',cascade=>true);
PL/SQL procedure
successfully completed.
SQL> exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP2',cascade=>true);
PL/SQL procedure
successfully completed.
SQL> exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP1',cascade=>true);
PL/SQL procedure
successfully completed.
SQL> exec
dbms_stats.gather_table_stats(ownname=>
'TEST',tabname=>'TESTTP',cascade=>true);
PL/SQL procedure
successfully completed.
3.查看用户下所有索引状态
SQL> select
index_name,tablespace_name,status from all_indexes where wner= 'TEST';
INDEX_NAME
------------------------------
TABLESPACE_NAME
STATUS
------------------------------------------------------------
--------
TESTTP3I
TEST1
VALID
TESTTP2I
TEST1
VALID
TESTTP1I
TEST1
VALID
4.将表迁移到新表空间中
conn
test/test
alter
table testtp move tablespace TEST2;
alter
table testtp1 move tablespace TEST2;
alter
table testtp2 move tablespace TEST2;
alter
table testtp3 move tablespace TEST2;
5.表迁移完成之后查看当前表空间和原表空间的表
SQL>
select table_name ,tablespace_name from dba_tables where tablespace_name =
'TEST1';
no
rows selected
SQL>
select table_name ,tablespace_name from dba_tables where tablespace_name =
'TEST2';
TABLE_NAME TABLESPACE_NAME
------------------------------
------------------------------
TESTTP TEST2
TESTTP1 TEST2
TESTTP2 TEST2
TESTTP3 TEST2
6.查看用户下所有索引状态
SQL> select
index_name,tablespace_name,status from all_indexes where wner= 'TEST';
INDEX_NAME
------------------------------
TABLESPACE_NAME
STATUS
------------------------------------------------------------
--------
TESTTP3I
TEST1
UNUSABLE
TESTTP2I
TEST1
UNUSABLE
TESTTP1I
TEST1
UNUSABLE
7.重建索引
生成重建索引语句
SQL> Select distinct
'alter index
'||b.owner||'.'||b.index_name||' rebuild online tablespace
'||tablespace_name||';' from dba_ind_columns a, dba_indexes b where
a.table_owner = b.owner and b.owner = 'TEST' and a.table_name in(select table_name
from all_indexes where wner= 'TEST' and STATUS='UNUSABLE') And a.index_name = b.index_name;
'ALTERINDEX'||B.OWNER||'.'||B.INDEX_NAME||'REBUILDONLINETABLESPACE'||TABLESPACE_
--------------------------------------------------------------------------------
alter index
TEST.TESTTP2I rebuild online tablespace TEST1;
alter index
TEST.TESTTP1I rebuild online tablespace TEST1;
alter index
TEST.TESTTP3I rebuild online tablespace TEST1;
8.查看用户下所有索引状态
SQL> select
index_name,tablespace_name,status from all_indexes where wner= 'TEST';
SQL> select
index_name,tablespace_name,status from all_indexes where wner= 'TEST';
INDEX_NAME
------------------------------
TABLESPACE_NAME STATUS
------------------------------------------------------------
--------
TESTTP3I
TEST1
VALID
TESTTP1I
TEST1
VALID
TESTTP2I
TEST1
VALID
9.重新进行表分析
略
oracle把表移到另一个表空间,将表迁移至其他表空间相关推荐
- php打开并填充表单,php – 创建一个’机器人’来填充带有一些页面的表单
表单通过发布数据来工作,因此您可以将数据发布到服务器,而不是使机器人在每个字段中键入内容并单击提交. 首先获取表单字段名称和表单的操作. 那么CURL: //set POST variables $u ...
- 人们通常先在线性表尾部临时添加一个_数据结构学习笔记-线性表
我们经常会处理一系列类型相同的数据, 创建这种元素组, 读取和修改 当我们处理一个具有有穷或者无穷的元素数据集的时候, 我们需要将其作为一个整体来管理和使用, 用变量去表示它们, 传入和传出函数等等. ...
- oracle分库分表原理_02. MyCat 的原理,应用场景,分库分表的思想
# MyCAT 作用是能够代替昂贵的oracle的MySQL集群中间件. 1) 一个彻底开源的,面向企业应用开发的"大数据库集群" 2) 支持事务.ACID.可以替代Mysql的加 ...
- oracle sql 分区查询语句_oracle11g 表分区后的查询语句如何知道是否进行了全表扫描...
2019-05-10 回答 1. 对返回的行无任何限定条件,即没有where 子句 2. 未对数据表与任何索引主列相对应的行限定条件 例如:在city-state-zip列创建了三列复合索引,那么仅对 ...
- 使用php创建一个注册表单,如何实现一个简单的注册表单
创建一个注册表单是非常容易的 - 它事实上意味着,你只需要创建一个表单,表单将更新一些User的模型对象(这个例子是一个Doctrine实体)并保存它. 受欢迎的FOSUserBundle 提供了一个 ...
- oracle 分表和分区哪个好_互联网大厂有哪些分库分表的思路和技巧?
点击上方蓝色"冰河技术",关注并选择"设为星标" 持之以恒,贵在坚持,每天进步一点点! 作者个人研发的在高并发场景下,提供的简单.稳定.可扩展的延迟消息队列框架 ...
- Oracle数据库迁移:异构传输表空间TTS HP-UX迁移至Redhat Linux 7.7
墨墨导读:本文来自墨天轮用户"你好我是李白"的投稿,记录一个Oracle数据库迁移过程 :异构传输表空间TTS HP-UX迁移至Redhat Linux 7.7.墨天轮主页:htt ...
- oracle外部表迁移,海量数据迁移之外部表并行抽取
在10g开始的新特性中,外部表是一个不容忽视的好工具.对于大型项目中海量数据使用sqlloader是一种全新的方式,不过很明显,sqlloader的可扩展性更强,但是基于oracle平台的数据迁移来说 ...
- ArcSDE for Oracle表空间管理——暂时(TEMP)表空间
Oracle暂时表空间主要用来做查询和存放一些缓冲区数据.暂时表空间消耗的主要原因是须要对查询的中间结果进行排序. 重新启动数据库能够释放暂时表空间,假设不能重新启动实例,而一直保持问题sql语句的运 ...
最新文章
- candence的图纸大小设置_在Orcad Cadence中设置原理图页码
- python界面设计实例-Python GUI项目实战(二)主窗体的界面设计与实现
- 杂谈:《宫锁心玉》的穿越硬伤
- Cow Relays POJ - 3613
- PyCharm设置字体大小(亲测)
- 构造函数 构造代码块_构造函数必须没有代码
- 从‘一边拉琴,一边哭’,看什么是真正的兴趣
- python gc_Python垃圾收集(Python GC)
- DoIP诊断概念入门
- java学生管理系统,(史上最全)
- 【玩转PDF】贼稳,产品要做一个三方合同签署,我方了!
- PAT题集2019.6.5排名变动
- IIS 发布网站无法显示CSS、背景及图片文件---另一个思路--终极方案
- 将Linux 标准输出,错误输出重定向到文件
- 论文笔记(二)Region Proposal by Guided Anchoring(CVPR2019)
- How to make seperate debuginfo file
- python图片转文字
- 教学方法(学科教学法)
- 还在用Navicat?这款开源的数据库管理工具界面更炫酷!
- oracle异地接管,群集的接管和故障恢复 - 
Oracle® ZFS Storage Appliance 管理指南,发行版 OS8.6.0...