How to Partition a Non-partitioned Table [ID 1070693.6]

How to Partition a Non-partitioned Table [ID 1070693.6]


 

Modified 03-MAR-2010     Type BULLETIN     Status PUBLISHED

 

 

 

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

 

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.

 

A. Export/import method

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

 

1)  Export your table:

 

    exp usr/pswd tables=numbers file=exp.dmp

 

2)  Drop the table:

 

    drop table numbers;

 

3)  Recreate the table with partitions:

 

    create table numbers (qty number(3), name varchar2(15))

    partition by range (qty)

    (partition p1 values less than (501),

     partition p2 values less than (maxvalue));

 

4)  Import the table with ignore=y:

 

    imp usr/pswd file=exp.dmp ignore=y

 

    The ignore=y causes the import to skip the table creation and

    continues to load all rows.

 

 

B. Insert with a subquery method

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

 

1)  Create a partitioned table:

 

    create table partbl (qty number(3), name varchar2(15))

    partition by range (qty)

    (partition p1 values less than (501),

     partition p2 values less than (maxvalue));

 

2)  Insert into the partitioned table with a subquery from the

    non-partitioned table:

 

    insert into partbl (qty, name)

       select * from origtbl;

 

3)  If you want the partitioned table to have the same name as the

    original table, then drop the original table and rename the

    new table:

 

    drop table origtbl;

    alter table partbl rename to origtbl;

 

C. Partition Exchange method

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

 

ALTER TABLE EXCHANGE PARTITION can be used to convert a partition (or

subpartition) into a non-partitioned table and a non-partitioned table into a

partition (or subpartition) of a partitioned table by exchanging their data

and index segments.

 

1) Create table dummy_t as select with the required partitions

 

2) Alter table EXCHANGE partition partition_name

       with table non-partition_table;

 

 

Example

-------

 

SQL> CREATE TABLE p_emp

   2     (sal NUMBER(7,2))

   3      PARTITION BY RANGE(sal)

   4      (partition emp_p1 VALUES LESS THAN (2000),

   5       partition emp_p2 VALUES LESS THAN (4000));

 Table created.

 

 

 SQL> SELECT * FROM emp;

     EMPNO ENAME      JOB             MGR HIREDATE        SAL

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

      7369 SMITH      CLERK          7902 17-DEC-80       800

      7499 ALLEN      SALESMAN       7698 20-FEB-81      1600

      7521 WARD       SALESMAN       7698 22-FEB-81      1250

      7566 JONES      MANAGER        7839 02-APR-81      2975

      7654 MARTIN     SALESMAN       7698 28-SEP-81      1250

      7698 BLAKE      MANAGER        7839 01-MAY-81      2850

      7782 CLARK      MANAGER        7839 09-JUN-81      2450

      7788 SCOTT      ANALYST        7566 19-APR-87      3000

      7839 KING       PRESIDENT           17-NOV-81      5000

      7844 TURNER     SALESMAN       7698 08-SEP-81      1500

      7876 ADAMS      CLERK          7788 23-MAY-87      1100

      7900 JAMES      CLERK          7698 03-DEC-81       950

      7902 FORD       ANALYST        7566 03-DEC-81      3000

      7934 MILLER     CLERK          7782 23-JAN-82      1300

 14 rows selected.

 

SQL> CREATE TABLE dummy_y as SELECT sal

 FROM emp WHERE  sal<2000;

 Table created.

 

SQL> CREATE TABLE dummy_z as SELECT sal FROM emp WHERE sal

 BETWEEN 2000 AND 3999;

 Table created.

 

SQL> alter table p_emp exchange partition emp_p1

 with table dummy_y;

 Table altered.

 

SQL> alter table p_emp exchange partition emp_p2

 with table dummy_z;

 Table altered.

 

 

D. DBMS_REDEFINITION

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

 

See Note 472449.1 "How To Partition Existing Table Using DBMS_Redefinition" for detailed instructions.

 

在线重定义参考:

http://blog.csdn.net/tianlesoftware/archive/2011/03/02/6218693.aspx

 

 

 

 

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

QQ: 492913789

Email:ahdba@qq.com

Blog: http://www.cndba.cn/dave



DBA1 群:62697716(); DBA2 群:62697977()

DBA3 群:62697850   DBA 超级群:63306533;    

聊天 群:40132017

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

### 关于 `partition_table` 和 `partition-table.bin` 的报错解决方案 当遇到与 `partition_table` 或者其对应的二进制文件 `partition-table.bin` 相关的错误时,通常是因为分区表配置不正确或者硬件兼容性问题引起的。以下是可能的原因以及相应的解决方法: #### 1. **分区表大小超出闪存容量** 如果分区表定义的内容超出了设备可用的闪存空间,则会引发错误。 - 验证 CSV 文件中定义的所有分区总大小是否小于设备的实际存储容量[^2]。 - 如果发现分区过大,调整分区大小以适应实际需求并重新生成二进制文件。 ```bash # 使用 esptool.py 查看当前设备的 flash 容量 esptool.py flash_id ``` #### 2. **分区类型或子类型的冲突** 某些情况下,指定的分区类型 (type) 或子类型 (subtype) 可能不符合 ESP-IDF 的预期设置。 - 检查 `esp_partition_type_t` 和 `esp_partition_subtype_t` 中的合法值,并确保在 CSV 文件中使用的类型和子类型匹配这些定义。 例如,在 `esp_partition.h` 中有如下定义: ```c typedef enum { ESP_PARTITION_TYPE_APP = 0x00, ESP_PARTITION_TYPE_DATA = 0x01, } esp_partition_type_t; ``` 对于应用分区 (`app`) 应该使用类型 `0x00`,而对于数据分区 (`data`) 则应使用类型 `0x01`。 #### 3. **CSV 转换为 BIN 过程中的错误** 转换过程中可能出现格式化错误或其他异常情况。 - 确认用于生成 `partition-table.bin` 的工具版本是最新的。 - 手动验证 CSV 文件语法无误后再运行命令将其转为二进制形式。 ```bash # 命令示例:将自定义 csv 文件编译成 bin 格式的分区表 parttool.py create-partition-table --output partition-table.bin my_custom_partitions.csv ``` #### 4. **烧录过程失败** 即使成功创建了有效的 `.bin` 文件,但如果上传到目标板卡时不遵循特定顺序也可能触发错误提示。 - 烧写前清除旧版固件残留记录; - 正确设定波特率参数以免通信中断影响传输质量; ```bash # 示例脚本片段展示如何利用 esptool 工具完成整个流程 esptool.py erase_flash && \ esptool.py write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 bootloader_dio_80m.bin 0x8000 partition-table.bin ... ``` 通过上述措施可以有效排查并修复大部分由 `partition_table` 导致的功能障碍现象。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值