1:整理分区表空间步骤记录

生产库满了,准确的应该说生产库的磁盘空间不够用了,老板说要重新上新设备和机器,为了暂时解决目前应用的需要,只好EXP备份出老数据,等新阵列配合RAC一起上的时候再导入回去。折腾,也是一种锻炼,记录如下:

 

1:整理空间步骤记录

 

1.1 确认表分区

确认sen02的记录和时间

SELECT 

count(*),min(G.START_DATE), max(G.START_DATE)

FROM ISGIS.GIS_SEN_DIST_INFO partition(sen02G;

 

 

确认分区结果:

COUNT(*)

MIN(G.START_DATE)

MAX(G.START_DATE)

222,489,976

04-01-2010 00:00:00

12-31-2010 23:59:36

 

1.2.计算导出文件的大小

导出文件和数据库中所占空间大小基本相等(我的结果是略比数据库空间略为少一点),使用如下语句判断要导出的表所占的空间:

select sum(u.bytes)/1024/1024

    from user_extents u

    where u.segment_name =upper('gis_vehicle_realtime_info')

and u.partition_name=upper('GPS_MAX');

 

计算结果:

SUM(U.BYTES)/1024/1024

21,056

 

1.3 EXP备份分区表

[oracle@localhost expdata]$ exp  isgis/isafegis  file=/backup/expdata/gps01_20110427.dmp tables=gis_vehicle_realtime_info:gps01  log=gps01_20110427_exp.log

 

 

Export: Release 10.2.0.1.0 - Production on Wed Apr 27 13:06:54 2011

 

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

 

 

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

Export done in US7ASCII character set and AL16UTF16 NCHAR character set

server uses AL32UTF8 character set (possible charset conversion)

 

About to export specified tables via Conventional Path ...

. . exporting table      GIS_VEHICLE_REALTIME_INFO

. . exporting partition                          GPS01     618379 rows exported

EXP-00091: Exporting questionable statistics.

EXP-00091: Exporting questionable statistics.

Export terminated successfully with warnings.

 

 

1.4 修正语言参数

    上面的导出中出现了错误提示,即EXP-00091,该错误表明exp工具所在的环境变量中的NLS_LANG与DB中的NLS_CHARACTERSET不一致尽管该错误对最终的数据并无影响,但调整该参数来避免异常还是有必要的。因此需要将其设置为一致即可解决上述的错误提示。

 

查看数据库字符集:select userenv('language') from dual;

SQL> select userenv('language') from dual;

 

USERENV('LANGUAGE')

----------------------------------------------------

AMERICAN_AMERICA.AL32UTF8

 

 

修改EXP工具环境的字符集变量:

export NLS_LANG='AMERICAN_AMERICA.AL32UTF8'

 

 

[root@localhost ~]# export NLS_LANG='AMERICAN_AMERICA.AL32UTF8'

[root@localhost ~]# echo $NLS_LANG

AMERICAN_AMERICA.AL32UTF8

再次导出,发现无警告信息。

 

 

1.4 清空该分区表

语法:alter  table  表名  truncate    partition   分区名;

 

SQL> alter  table  isgis.gis_vehicle_realtime_info  truncate    partition   gps01;

 

Table truncated.

 

 

1.5 恢复分区表

语法:imp  isgis/isafegis   file=/backup/expdata/gps01_20110427.dmp tables=gis_vehicle_realtime_info:gps01  log=/backup/expdata/gps01_20110427_imp.log  ignore=y  

 

 

 

[oracle@localhost expdata]$ imp  isgis/isafegis   file=/backup/expdata/gps01_20110427.dmp tables=gis_vehicle_realtime_info:gps01  log=/backup/expdata/gps01_20110427_imp.log ignore=y

 

Import: Release 10.2.0.1.0 - Production on Wed Apr 27 16:10:30 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

 

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

 

Export file created by EXPORT:V10.02.01 via conventional path

import done in AL32UTF8 character set and AL16UTF16 NCHAR character set

. importing ISGIS's objects into ISGIS

. importing ISGIS's objects into ISGIS

. . importing partition "GIS_VEHICLE_REALTIME_INFO":"GPS01"     621697 rows imported

Import terminated successfully without warnings.

 

exp isgis/isafegis file=/backup/expdata/gps01_20110427.dmp tables=gis_vehicle_realtime_info:gps01 log=_20110427_exp.log

 

1.6 索引维护(重新建立)

(1) 使用如下语句进行自动恢复索引

SQL> alter table analyse_content truncate  partition DATA0712_ZIGONG UPDATE

GLOBAL INDEXES;

Table truncated

(2)查看索引的状态

       SQL> select index_name ,status from dba_indexes where table_name='名称'; 

select  index_name ,status from dba_indexes where table_name=upper('gis_vehicle_realtime_info')

(3) 重建rebuild index

truncate分区后,修改或者插入数据报错:

ORA-01502: index 'phs.pk' or partition of such index is in unusable state

这个时候只能rebuild index

SQL> alter index phs.pk rebuild online;

Index altered

执行以后恢复正常

 

Ps:这里的ignore=y 由于是分区表必须添加,否则会报错。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值