免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8092 | 回复: 8
打印 上一主题 下一主题

oracle 9i全库exp/imp时,分区表的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-11 14:25 |只看该作者 |倒序浏览
对oracle 9i数据库进行数据迁移。数据库导出按用户全库导出。脚本如下:
exp user/password buffer=40960 filesize=1536m file=1.dmp,2.dmp......20.dmp direct=Y  owner=user rows=y compress=y indexes=n log=exp.log
原库的一个数据表按行号进行分区,分了8个区(每个分区60万行)。因为数据增长过快,将原来分了8个区的表重新分区,成为24个(每个分区75万行)。在新的服务器上建好数据库和用户后,将数据表及分区创建好(24个分区的表),执行导入脚本:
imp user/password file=1.dmp,2.dmp,......20.dmp fromuser=user touser=user ignore=y  commit=y grants=n  log=imp.log
导入过程中查看导入信息发现:
原数据库数据表每个分区导出的数据导入到新表中时,并未按照新表的存储方式存储,例如:原表分区1导出311829行,导入到新表分区1时也还是311829行,不单这一个分区,目前开始导入第8个分区,所有的分区都出现这个情况。
我理解当分区条件改变时,全库导入数据数据表会按照新的数据分区方式进行存储,为什么会出现这个原因呢?希望大家能够帮忙解答,谢谢!

论坛徽章:
0
2 [报告]
发表于 2007-01-11 15:03 |只看该作者
create table test_p1
(
   id  number(5)
)
partition by range(id)
(
   partition test_p1_p1 values less than (10),
   partition test_p1_p2 values less than (20),
   partition test_p1_p3 values less than (30)
);

SQL> create table test_p1                              
  2  (                                                
  3     id  number(5)                                 
  4  )                                                
  5  partition by range(id)                           
  6  (                                                
  7     partition test_p1_p1 values less than (10),   
  8     partition test_p1_p2 values less than (20),   
  9     partition test_p1_p3 values less than (30)     
10  );                                                

Table created.

SQL> insert into test_p1 values(2);

1 row created.

SQL> insert into test_p1 values(12);

1 row created.

SQL> insert into test_p1 values(18);

1 row created.

SQL> insert into test_p1 values(22);

1 row created.

SQL> insert into test_p1 values(28);

1 row created.

SQL> insert into test_p1 values(8);

1 row created.

SQL> commit;

Commit complete.


SQL> select * from test_p1 partition(test_p1_p2);

        ID
----------
        12
        18

SQL> select * from test_p1 partition(test_p1_p3);

        ID
----------
        22
        28

SQL> select * from test_p1 partition(test_p1_p1);

        ID
----------
         2
         8
         
[oracle@localhost ~]$ exp test/test file=/tmp/test.dmp tables=test_p1

Export: Release 10.2.0.1.0 - Production on Sat Jan 6 07:17:47 2007

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


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning and Data Mining options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table                        TEST_P1
. . exporting partition                     TEST_P1_P1          2 rows exported
. . exporting partition                     TEST_P1_P2          2 rows exported
. . exporting partition                     TEST_P1_P3          2 rows exported
Export terminated successfully without warnings.

论坛徽章:
0
3 [报告]
发表于 2007-01-11 15:04 |只看该作者
drop table test_p1;

create table test_p1
(
   id  number(5)
)
partition by range(id)
(
   partition test_p1_p1 values less than (5),
   partition test_p1_p2 values less than (15),
   partition test_p1_p3 values less than (25),
   partition test_p1_p4 values less than (35)
);

SQL> create table test_p1
  2  (
  3     id  number(5)
  4  )
  5  partition by range(id)
  6  (
  7     partition test_p1_p1 values less than (5),
  8     partition test_p1_p2 values less than (15),
  9     partition test_p1_p3 values less than (25),
10     partition test_p1_p4 values less than (35)
11  );

Table created.


[oracle@localhost ~]$ imp test/test file=/tmp/test.dmp tables=test_p1 ignore=y

Import: Release 10.2.0.1.0 - Production on Sat Jan 6 07:18:48 2007

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


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing TEST's objects into TEST
. importing TEST's objects into TEST
. . importing partition         "TEST_P1":"TEST_P1_P1"          2 rows imported
. . importing partition         "TEST_P1":"TEST_P1_P2"          2 rows imported
. . importing partition         "TEST_P1":"TEST_P1_P3"          2 rows imported
Import terminated successfully without warnings.

SQL> select * from test_p1 partition(test_p1_p1);

        ID
----------
         2

SQL> select * from test_p1 partition(test_p1_p2);

        ID
----------
         8
        12

SQL> select * from test_p1 partition(test_p1_p3);

        ID
----------
        18
        22

SQL> select * from test_p1 partition(test_p1_p4);

        ID
----------
        28

论坛徽章:
0
4 [报告]
发表于 2007-01-11 15:06 |只看该作者
imp的提示信息是说明原来导出的哪些partition数据都已经导入成功。并没有包含这些数据现在保存的方式有没有改动。

论坛徽章:
0
5 [报告]
发表于 2007-01-11 15:18 |只看该作者
我明白了,实际你看到的导入日志还是按照你导出时的数据行数来显示,但是在新数据库里的存储方式实际已经发生了变化并且按照事先设定好的方式进行数据存储。如果真是这样,我担心的问题就已经解决了。非常感谢numenhuang!

论坛徽章:
0
6 [报告]
发表于 2007-01-11 15:21 |只看该作者
原帖由 打喷嚏 于 2007-1-11 15:18 发表
我明白了,实际你看到的导入日志还是按照你导出时的数据行数来显示,但是在新数据库里的存储方式实际已经发生了变化并且按照事先设定好的方式进行数据存储。如果真是这样,我担心的问题就已经解决了。非常感谢num ...


可以进行相应的查询来进行核对。

论坛徽章:
0
7 [报告]
发表于 2012-05-22 17:13 |只看该作者
谢谢。这个对我帮助很大。正在愁有没有快速、安全、稳妥实现普通表向分区表转换的法子。此帖给了我思路。

论坛徽章:
0
8 [报告]
发表于 2012-05-22 17:13 |只看该作者
You can partition a non-partitioned table in one of four ways:
A) Export/import method
B) Insert with a subquery method
C) Partition exchange method
D) DBMS_REDEFINITION
Either of these four methods will create a partitioned table from an existing non-partitioned table.

论坛徽章:
0
9 [报告]
发表于 2012-05-22 17:14 |只看该作者
PURPOSE
You have a table that is not partitioned that you would like to make into a partitioned table. This article describes four possible methods for partitioning a non-partitioned table.
These steps can also be used to change other partitioning characteristics such as adding subpartitioning to a partitioned table.
SCOPE & APPLICATION
Users needing to partition a non-partitioned table.
RELATED DOCUMENTS
Note:72332.1 DIAGNOSING ORA-14097 ON ALTER TABLE EXCHANGE PARTITION
Note:105317.1 Section "VII.7 Partition exchanges
Note:472449.1        How To Partition Existing Table Using DBMS_Redefinition
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP