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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- create table進階學習系列(十一)之cluster
- create table進階學習系列(八)
- create table進階學習系列(五)
- create table進階學習系列(七)
- create table進階學習系列(九)
- create table進階學習(一)
- create table進階學習(三)
- create table進階學習(四)
- create table進階學習(二)_全域性臨時表_global temporary table
- create table進階學習(二)_dba_free_temp_space_v$tempseg_usage_v$sort_segment
- Python爬蟲學習之(二)| urllib進階篇Python爬蟲
- CREATE TABLE AS SELECT(CAST)(二)-ConceptAST
- 《大前端進階 Node.js》系列 雙十一秒殺系統(進階必看)前端Node.js
- Redux 進階 – react 全家桶學習筆記(二)ReduxReact筆記
- Redux 進階 - react 全家桶學習筆記(二)ReduxReact筆記
- (二)《SQL進階教程》學習記錄--GROUP BY、PARTITION BYSQL
- (十一)TestNG學習之路—BeanShell高階用法Bean
- Node進階學習
- 學習進度 (待續)
- oracle create table官方手冊如何快速檢視學習方法Oracle
- Java進階學習之Java架構師的學習路線Java架構
- 人臉識別學習筆記二:進階篇筆記
- html5進階學習第二天HTML
- Python進階學習之程式碼閱讀Python
- Java進階學習之集合與泛型(1)Java泛型
- oracle學習筆記(十一) 高階查詢Oracle筆記
- .NET進階系列之四:深入DataTable
- Java進階容器學習Java
- create table之storage選項initial和其它
- Hadoop 學習系列(二)之 HDFS 詳細解析Hadoop
- hive學習筆記之十一:UDTFHive筆記
- JUnit5學習之八:綜合進階(終篇)
- Python進階學習分享之迴圈設計Python
- Hive學習之六 《Hive進階— —hive jdbc》 詳解HiveJDBC
- create table of mysql databaseMySqlDatabase
- [Redis 系列]redis 學習二Redis
- 【Redis 系列】redis 學習二Redis
- Go語言核心36講(Go語言進階技術十一)--學習筆記Go筆記