简体   繁体   English

如何在 Oracle 12c 中基于一个整数列(每个值 = 1 个分区)创建分区表?

[英]How to create partitioned table based on one Integer column (each value = 1 partition) in Oracle 12c?

There is a non-partitioned table in Oracle 12c, call it 't1' with 10M records that has 3 columns (a,b,c). Oracle 12c 中有一个未分区的表,将其称为“t1”,其中包含 10M 条记录,其中包含 3 列 (a,b,c)。

Column 'a' has 100 distinct integer values.列 'a' 有 100 个不同的整数值。

How to create a second table 't2' that has all the values from 't1' but is partitioned based on column 'a' so that each partition correspond to one distinct value in column 'a'?如何创建第二个表 't2',其中包含来自 't1' 的所有值但基于列 'a' 进行分区,以便每个分区对应于列 'a' 中的一个不同值? (there should be 100 partitions created). (应该创建 100 个分区)。

Thanks!谢谢!

Create a automatic list partition while creating table t2 and later insert records from table t1 which will create a new partition for each distinct value in the mentioned column 'a'.创建表 t2 时创建一个自动列表分区,稍后从表 t1 插入记录,这将为提到的列 'a' 中的每个不同值创建一个新分区。

Note : While creating automatic list partition you need to specify atleast one partition.注意:创建自动列表分区时,您需要至少指定一个分区。

eg :- CREATE TABLE t2 ( a number,b varchar2(200),c varchar2(200) ) PARTITION BY LIST (a) AUTOMATIC ( PARTITION P_10 VALUES (10) );例如:- CREATE TABLE t2 (a number,b varchar2(200),c varchar2(200)) PARTITION BY LIST (a) AUTOMATIC (PARTITION P_10 VALUES (10) );

insert into t2 select * from t1;插入 t2 select * from t1;

This insert will create partitions automatically for each distinct value.此插入将为每个不同的值自动创建分区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Oracle 12c-如何对现有表进行分区? - Oracle 12c - how to partition existing table? Oracle 12c-如何从一列转换为另一列 - Oracle 12c - how to cast from one column to another 如何在oracle 12c中创建用户 - how to create a user in oracle 12c 如何在 Oracle SQL 中将多个列值组合成单个值作为逗号分隔的字符串(Oracle Forms 12c) - How to combine more than one column values into single value as a comma separated string in Oracle SQL (Oracle Forms 12c) Oracle 12c-根据不同表中的值动态生成where子句 - Oracle 12c - dynamically generate a where clause based on a value in a different table Oracle 12c将列添加到表中而没有默认值会花费很长时间 - Oracle 12c Adding Column to table without default value taking really long Oracle 12C - JSON_TABLE - 当 json 列为 null 时如何返回表中的其他列 - Oracle 12C - JSON_TABLE - How to return other columns in the table when json column is null 将多个表关联到一个表[SQL-Oracle 12c] - Relating Multiple Tables to One Table [SQL - Oracle 12c] Oracle 12c - 如何查看某个表的所有分区和子分区以及每个表的记录数 - Oracle 12c - how to see all partitions and sub-partitions for some table and number of records for each 如何在Oracle 12c中使用多个数据更新单个列 - How to update a single column with multiple data in oracle 12c
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM