Column definition incompatible with clustered column definition

老子叫甜甜 提交于 2021-01-28 22:03:47

问题


I have created a cluster in Oracle

CREATE  CLUSTER myLovelyCluster (clust_id NUMBER(38,0))
SIZE 1024 SINGLE TABLE HASHKEYS 11;

Than a table for the cluster

 CREATE TABLE Table_cluster
CLUSTER myLovelyCluster (columnRandom)
AS SELECT * FROM myTable ;

the columnRandom is well defined as NUMBER(38,0) but why I am getting an error assuming incompatible column definition?

Thanks


回答1:


Are you sure that columnRandom is number(38,0)? In oracle NUMBER != NUMBER(38,0)

Let's create two table.

create table src_table ( a number);
create table src_table2( a number(38,0));

select column_name,data_precision,Data_scale from user_tab_cols where table_name like 'SRC_TABLE%';

Result of query is. Definitions of column are different.

+-------------+----------------+------------+
| Column_name | Data_Precision | Data_scale |
+-------------+----------------+------------+
| A           |                |            |
| A           |             38 |          0 |
+-------------+----------------+------------+

And if i try creat cluster for first table.

CREATE TABLE Table_cluster
CLUSTER myLovelyCluster (a)
AS SELECT * FROM src_table ;

ORA-01753: column definition incompatible with clustered column definition

For 2-nd every thing is ok.

CREATE TABLE Table_cluster
CLUSTER myLovelyCluster (a)
AS SELECT * FROM src_table2 ;

If you add cast into select. Execution also is correct.

CREATE TABLE Table_cluster CLUSTER myLovelyCluster  (a)
AS SELECT cast(a as number(38,0)) FROM src_table;


来源:https://stackoverflow.com/questions/40477654/column-definition-incompatible-with-clustered-column-definition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!