create table進階學習系列(十一)之cluster_續(二)
SQL> select cluster_name,tablespace_name from user_clusters;
CLUSTER_NAME TABLESPACE_NAME
------------------------------ ------------------------------
CLUSTER1 TBS_HANG
CLUSTER_NAME TABLESPACE_NAME
------------------------------ ------------------------------
CLUSTER1 TBS_HANG
---查詢cluster table資訊
SQL> desc user_clu_columns;
Name Type Nullable Default Comments
--------------- -------------- -------- ------- -----------------------------------------------------
CLUSTER_NAME VARCHAR2(30) Cluster name
CLU_COLUMN_NAME VARCHAR2(30) Key column in the cluster
TABLE_NAME VARCHAR2(30) Clustered table name
TAB_COLUMN_NAME VARCHAR2(4000) Y Key column or attribute of object column in the table
SQL> select cluster_name,clu_column_name,table_name,tab_column_name from user_clu_columns;
CLUSTER_NAME CLU_COLUMN_NAME TABLE_NAME TAB_COLUMN_NAME
------------------------------ ------------------------------ ------------------------------ --------------------------------------------------------------------------------
CLUSTER1 A T_TEST A
CLUSTER1 A T_TEST_LOB A
---查詢cluster hash表示式資訊
SQL> desc user_cluster_hash_expressions;
Name Type Nullable Default Comments
--------------- ------------ -------- ------- --------------------------------
OWNER VARCHAR2(30) Name of owner of cluster
CLUSTER_NAME VARCHAR2(30) Name of cluster
HASH_EXPRESSION LONG Y Text of hash function of cluster
SQL> desc user_clu_columns;
Name Type Nullable Default Comments
--------------- -------------- -------- ------- -----------------------------------------------------
CLUSTER_NAME VARCHAR2(30) Cluster name
CLU_COLUMN_NAME VARCHAR2(30) Key column in the cluster
TABLE_NAME VARCHAR2(30) Clustered table name
TAB_COLUMN_NAME VARCHAR2(4000) Y Key column or attribute of object column in the table
SQL> select cluster_name,clu_column_name,table_name,tab_column_name from user_clu_columns;
CLUSTER_NAME CLU_COLUMN_NAME TABLE_NAME TAB_COLUMN_NAME
------------------------------ ------------------------------ ------------------------------ --------------------------------------------------------------------------------
CLUSTER1 A T_TEST A
CLUSTER1 A T_TEST_LOB A
---查詢cluster hash表示式資訊
SQL> desc user_cluster_hash_expressions;
Name Type Nullable Default Comments
--------------- ------------ -------- ------- --------------------------------
OWNER VARCHAR2(30) Name of owner of cluster
CLUSTER_NAME VARCHAR2(30) Name of cluster
HASH_EXPRESSION LONG Y Text of hash function of cluster
----cluster鍵列的操作限制
Restrictions on Cluster Data Types Cluster data types are subject to the following restrictions:
-----資料型別不能是long,blob,clob等
You cannot specify a cluster key column of data type LONG, LONG RAW, REF, nested table, varray, BLOB, CLOB, BFILE, the Any* Oracle-supplied types,
or user-defined object type.
--可以指定資料型別為rowid,但oracle不保證其列上的值為合理的rowid
You can specify a column of type ROWID, but Oracle Database does not guarantee that the values in such columns are valid rowids.
You cannot specify a cluster key column of data type LONG, LONG RAW, REF, nested table, varray, BLOB, CLOB, BFILE, the Any* Oracle-supplied types,
or user-defined object type.
--可以指定資料型別為rowid,但oracle不保證其列上的值為合理的rowid
You can specify a column of type ROWID, but Oracle Database does not guarantee that the values in such columns are valid rowids.
---如刪除cluster須先刪除其屬表
SQL> drop cluster cluster1;
drop cluster cluster1
ORA-00951: cluster not empty
SQL> drop table t_test purge;
Table dropped
SQL> drop table t_test_lob purge;
Table dropped
SQL> drop cluster cluster1;
Cluster dropped
----測試hash cluster
SQL> create cluster cluster1(a int) hashkeys 10;
Cluster created
SQL> desc user_cluster_hash_expressions;
Name Type Nullable Default Comments
--------------- ------------ -------- ------- --------------------------------
OWNER VARCHAR2(30) Name of owner of cluster
CLUSTER_NAME VARCHAR2(30) Name of cluster
HASH_EXPRESSION LONG Y Text of hash function of cluster
SQL> select owner,cluster_name,hash_expression from user_cluster_hash_expressions;
OWNER CLUSTER_NAME HASH_EXPRESSION
------------------------------ ------------------------------ --------------------------------------------------------------------------------
SQL> drop cluster cluster1;
Cluster dropped
---如下指定hash keys
--hash keys語義
HASHKEYS Clause
----hashkeys指定hash cluster有多少個hash value
Specify the HASHKEYS clause to create a hash cluster and specify the number of hash values for the hash cluster.
---oracle會把hash value相同的記錄儲存在一起
In a hash cluster, Oracle Database stores together rows that have the same hash key value. The hash value for a row
is the value returned by the hash function of the cluster.
---oracle會採用四捨五入的方法計算hashkeys的值,最小值為2;如你忽略index和hashkeys,oracle預設建立index cluster
Oracle Database rounds up the HASHKEYS value to the nearest prime number to obtain the actual number of hash values.
The minimum value for this parameter is 2. If you omit both the INDEX clause and the HASHKEYS parameter, then the
database creates an indexed cluster by default.
----hashkeys指定hash cluster有多少個hash value
Specify the HASHKEYS clause to create a hash cluster and specify the number of hash values for the hash cluster.
---oracle會把hash value相同的記錄儲存在一起
In a hash cluster, Oracle Database stores together rows that have the same hash key value. The hash value for a row
is the value returned by the hash function of the cluster.
---oracle會採用四捨五入的方法計算hashkeys的值,最小值為2;如你忽略index和hashkeys,oracle預設建立index cluster
Oracle Database rounds up the HASHKEYS value to the nearest prime number to obtain the actual number of hash values.
The minimum value for this parameter is 2. If you omit both the INDEX clause and the HASHKEYS parameter, then the
database creates an indexed cluster by default.
----你建立hash cluster,oracle馬上根據size和hashkeys引數值分配空間
When you create a hash cluster, the database immediately allocates space for the cluster based on the values of the
SIZE and HASHKEYS parameters.
When you create a hash cluster, the database immediately allocates space for the cluster based on the values of the
SIZE and HASHKEYS parameters.
SQL> create cluster cluster1(a int) hashkeys 10 hash is mod(a,15);
Cluster created
SQL> select owner,cluster_name,hash_expression from user_cluster_hash_expressions;
OWNER CLUSTER_NAME HASH_EXPRESSION
------------------------------ ------------------------------ --------------------------------------------------------------------------------
SCOTT CLUSTER1 mod(a,15)
SQL> drop cluster cluster1;
Cluster dropped
---hash is指定自定義的hash function,否則採用oracle預設hash function
SQL> create cluster cluster1(a int) hashkeys 10 hash is mod(a,15) size 512;
Cluster created
SQL> drop cluster cluster1;
Cluster dropped
SQL> create cluster cluster1(a int) hashkeys 10 hash is mod(a,15) size 512;
Cluster created
SQL> drop cluster cluster1;
Cluster dropped
---single table表示cluster僅含一個table
SQL> create cluster cluster1(a int) hashkeys 10 hash is mod(a,15) size 512 single table;
Cluster created
SQL> create table t_test(a int) cluster cluster1;
create table t_test(a int) cluster cluster1
ORA-00906: missing left parenthesis
SQL> create table t_test(a int) cluster cluster1(a);
Table created
SQL> create table t_test_2(a int,b int) cluster cluster1(a);
create table t_test_2(a int,b int) cluster cluster1(a)
ORA-25136: this cluster can contain only one table
SQL> create cluster cluster1(a int) hashkeys 10 hash is mod(a,15) size 512 single table;
Cluster created
SQL> create table t_test(a int) cluster cluster1;
create table t_test(a int) cluster cluster1
ORA-00906: missing left parenthesis
SQL> create table t_test(a int) cluster cluster1(a);
Table created
SQL> create table t_test_2(a int,b int) cluster cluster1(a);
create table t_test_2(a int,b int) cluster cluster1(a)
ORA-25136: this cluster can contain only one table
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-753249/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 《大前端進階 Node.js》系列 雙十一秒殺系統(進階必看)前端Node.js
- Redux 進階 – react 全家桶學習筆記(二)ReduxReact筆記
- Redux 進階 - react 全家桶學習筆記(二)ReduxReact筆記
- (二)《SQL進階教程》學習記錄--GROUP BY、PARTITION BYSQL
- Python進階學習之程式碼閱讀Python
- (十一)TestNG學習之路—BeanShell高階用法Bean
- Hadoop 學習系列(二)之 HDFS 詳細解析Hadoop
- 快速學習nodejs系列:十一、nodejs垃圾回收NodeJS
- 學習進度 (待續)
- Java進階學習之Java架構師的學習路線Java架構
- 人臉識別學習筆記二:進階篇筆記
- html5進階學習第二天HTML
- 機器學習進階 第二節 第八課機器學習
- Python進階學習分享之迴圈設計Python
- Java進階學習之集合與泛型(1)Java泛型
- create table,show tables,describe table,DROP TABLE,ALTER TABLE ,怎麼使用?
- oracle學習筆記(十一) 高階查詢Oracle筆記
- Kubernetes的Pod進階(十一)
- ReactNative學習筆記十一之FlatListReact筆記
- hive學習筆記之十一:UDTFHive筆記
- 【Android進階】RecyclerView之快取(二)AndroidView快取
- Java進階容器學習Java
- JavaEE進階知識學習-----SpringCloud(二)實踐準備JavaSpringGCCloud
- [Redis 系列]redis 學習二Redis
- 【Redis 系列】redis 學習二Redis
- Go語言核心36講(Go語言進階技術十一)--學習筆記Go筆記
- 線段樹進階應用學習筆記(二)+普通資料結構進階應用學習筆記(一)(2024.10.1)筆記資料結構
- JUnit5學習之八:綜合進階(終篇)
- linux進階命令學習一Linux
- Swift進階學習筆記Swift筆記
- Java學習路線·進階Java
- Python學習路線·進階Python
- Go 進階學習筆記Go筆記
- Vue 進階系列(二)之外掛原理及實現Vue
- shiro實戰系列(二)之入門實戰續
- MySQL5.6 create table原理分析MySql
- Java NIO學習系列二:ChannelJava
- Java進階專題(十一) 探究JMMJava
- 《MySQL 進階篇》二十一:MVCCMySqlMVC