确认sen02的记录和时间
SELECT
count(*),min(G.START_DATE), max(G.START_DATE)
FROM ISGIS.GIS_SEN_DIST_INFO partition(sen02) G;
确认分区结果:
COUNT(*) |
MIN(G.START_DATE) |
MAX(G.START_DATE) |
222,489,976 |
04-01-2010Â 00:00:00 |
12-31-2010Â 23:59:36 |
导出文件和数据库中所占空间大小基本相等(我的结果是略比数据库空间略为少一点),使用如下语句判断要导出的表所占的空间:
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 |
[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.
上面的导出中出现了错误提示,即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
再次导出,发现无警告信息。
语法:alter table 表名 truncate partition 分区名;
SQL> alter table isgis.gis_vehicle_realtime_info truncate partition gps01;
Table truncated.
语法: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) 使用如下语句进行自动恢复索引
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 由于是分区表必须添加,否则会报错。