博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
move分区表
阅读量:2447 次
发布时间:2019-05-10

本文共 2943 字,大约阅读时间需要 9 分钟。

现在需要将一些分区表移到别的表空间下去,且该表是arc表,目前是没有任何程序访问,不需使用在线重定义,可以直接move.

SQL> alter table JUSTIN move tablespace ARC;
alter table JUSTIN move tablespace ARC
            *
ERROR at line 1:
ORA-14511: cannot perform. operation on a partitioned object

分区表必须以分区为单位进行move,可以使用以下sql

Elapsed: 00:00:00.00

SQL> select 'alter table '||table_name||' move partition '||partition_name||' tablespace ARC;' from user_tab_partitions where table_name ='JUSTIN';

'ALTERTABLE'||TABLE_NAME||'MOVEPARTITION'||PARTITION_NAME||'TABLESPACEARC

--------------------------------------------------------------------------------
alter table JUSTIN move partition P0912 tablespace ARC;
alter table JUSTIN move partition P1003 tablespace ARC;
alter table JUSTIN move partition P1006 tablespace ARC;
alter table JUSTIN move partition P1009 tablespace ARC;
alter table JUSTIN move partition P1012 tablespace ARC;
alter table JUSTIN move partition P1103 tablespace ARC;
alter table JUSTIN move partition P1106 tablespace ARC;
alter table JUSTIN move partition P1109 tablespace ARC;
alter table JUSTIN move partition P1112 tablespace ARC;
alter table JUSTIN move partition P1203 tablespace ARC;
alter table JUSTIN move partition P1206 tablespace ARC;

11 rows selected.

Elapsed: 00:00:00.07

SQL> alter table JUSTIN move partition P0912 tablespace ARC;
alter table JUSTIN move partition P1003 tablespace ARC;
alter table JUSTIN move partition P1006 tablespace ARC;
alter table JUSTIN move partition P1009 tablespace ARC;
alter table JUSTIN move partition P1012 tablespace ARC;
alter table JUSTIN move partition P1103 tablespace ARC;
alter table JUSTIN move partition P1106 tablespace ARC;
alter table JUSTIN move partition P1109 tablespace ARC;
alter table JUSTIN move partition P1112 tablespace ARC;
alter table JUSTIN move partition P1203 tablespace ARC;
alter table JUSTIN move partition P1206 tablespace ARC;

Table altered.

Elapsed: 00:00:16.12

SQL>
Table altered.

Elapsed: 00:00:06.99

SQL>
Table altered.

Elapsed: 00:00:13.04

SQL>
Table altered.

Elapsed: 00:00:20.05

SQL>
Table altered.

Elapsed: 00:00:07.36

SQL>
Table altered.

Elapsed: 00:00:00.07

SQL>
Table altered.

Elapsed: 00:00:00.03

SQL>
Table altered.

Elapsed: 00:00:00.04

SQL>
Table altered.

Elapsed: 00:00:00.04

SQL>
Table altered.

Elapsed: 00:00:00.04

SQL>
Table altered.

Elapsed: 00:00:00.03

接下来需要重建索引,分区表上的索引分为分区索引和全局索引,需要区别开来进行重建
重建分区索引
SQL> select 'alter index '||index_name||' rebuild partition '||partition_name||' online tablespace  ARC;' from user_ind_partitions where index_name in (
  2  select index_name from user_indexes where table_name ='JUSTIN')  status != 'USABLE';

no rows selected

重建全局索引
SQL> select 'alter index '||index_name||' rebuild online tablespace  ARC;' from user_indexes where table_name ='JUSTIN'
  2  and status != 'USABLE';

no rows selected

不过这个arch表没有索引,那就不需要重建了,move完成。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15480802/viewspace-709372/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/15480802/viewspace-709372/

你可能感兴趣的文章
normal forms_使用Google Forms轻松创建基于Web的调查
查看>>
word文档插入复选框_如何将复选框添加到Word文档
查看>>
sql truncate_如何在SQL Delete和SQL Truncate语句后使用数据库备份恢复数据
查看>>
为SQL Server Always On可用性组配置域控制器和Active Directory
查看>>
SQL Server连接面试SQL Server数据库管理员问答
查看>>
ssisdb_SSISDB入门
查看>>
如何在SQL Server Management Studio中创建和配置链接服务器以连接到MySQL
查看>>
使用PowerShell和T-SQL在多服务器环境中规划SQL Server备份和还原策略
查看>>
ansi_nulls_影响查询结果SQL Server SET选项-SET ANSI_NULLS,SET ANSI_PADDING,SET ANSI_WARNINGS和SET ARITHABORT
查看>>
使用Microsoft数据迁移助手在Oracle数据库和SQL Server之间迁移的具体示例
查看>>
大数据数据科学家常用面试题_面试有关数据科学,数据理解和准备的问答
查看>>
sql2012 ssrs_如何在SQL Server并行数据仓库中处理SSRS多值参数过滤
查看>>
使用Azure Data Studio在Docker容器上使用SQL Server 2017进行备份和还原操作
查看>>
使用sql语句生成报表_SQL Server报表服务:如何使用报表生成器处理常见的最终用户要求
查看>>
如何使用SQL Server 2016系统版本的时态表跟踪数据更改的历史记录
查看>>
sql语句集合里有集合_学习SQL:集合论
查看>>
mac命令行将输出写入文件_如何使用命令行将备份,文件和脚本迁移到云中/从云中迁移
查看>>
sql数据库性能指标_SQL Server磁盘性能指标–第2部分–其他重要的磁盘性能指标
查看>>
sql数据库性能指标_SQL Server磁盘性能指标–第1部分–最重要的磁盘性能指标
查看>>
SQL Server复制
查看>>