




已閱讀5頁,還剩4頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
ObjectivesStoring User Data Regular tables Partitioned tables Index-organized tables Clustered tables普通表分區(qū)表 : 如果一個(gè)表太大了,那么就會(huì)在這個(gè)大表的基礎(chǔ)上,在分為子表,叫做 partition. 每個(gè) row 是存儲(chǔ)在一起的,比如 有1000行數(shù)據(jù),可能 前 500 rows 存儲(chǔ)在一個(gè) partition 里邊,后 500 rows 存儲(chǔ)在一個(gè) partition里。每個(gè)分區(qū)是一個(gè) segment, 并且可以存儲(chǔ)在不同的tablespace中。Index-organized tables : 這個(gè)“索引表” 不同于以往意義的索引,它是將存儲(chǔ)的數(shù)據(jù)本身按照某種順序進(jìn)行了存儲(chǔ),所以查詢效率很高。with a primary key index on one or more of its columns. an index-organized table maintains a single B- tree containing the primary key of the table and other column values.集群 : Clustered tables , 很多表是有相關(guān)性的,比如 Join 多個(gè)表,那么,可以將多個(gè)表存儲(chǔ)為集群,這樣在查詢時(shí)會(huì)提高效率。Clusters have a cluster key, which is used to identify the rows that need to be stored together.cluster key can consist of one or more columns.Tables in a cluster have columns that correspond to the cluster key.The cluster key is independent of the primary key.Data Type99% 用的是 built-in 類型, 99% 使用 Scalar數(shù)字型,文本型,日期型,二進(jìn)制( LOB )盡量用 varchar2 , 不要使用 char, 除非是固定格式,比如性別,只有 男,女如果 oracle 內(nèi)部表的列數(shù)超過 254列,oracle 會(huì)將一行 分成幾塊來存儲(chǔ)。會(huì)加重 I/O 負(fù)荷。索引是依附于表的。對(duì)于任何一張表都有 ROWID,隱含的。select ROWID, ID, NAME from employee;ROWID 的內(nèi)容, 可以看到 ROWID 可以快速定位一條記錄的位置。Table Structure90% 一行放在一個(gè) database block 中。( 一個(gè) database block 中還可以放行 )列存儲(chǔ)的順序通常就是你定義的列的順序,并且如果某列的值是 NULL, 那么是不會(huì)存儲(chǔ)該列的。Row data is stored in database blocks as variable-length records.columns for a row are generally stored in the order in which they are defined and any trailing NULL are not stored. Note: A single byte for column length is required for non trailing NULL columns.Each row in a table may have a different number of columns. Each row in a table has :row header : 這行有多少列,還有鏈接信息,還有鎖的情況。row lockrow data : 存儲(chǔ)列的長度,還有列的值。列的值是緊挨著列的長度信息。 for each column, the oracle server stores the column length and value ( one byte is needed to store the column length if the column cannot exceed 250 bytes. A column that can be longer needs three length bytes. The column value is stored immediately following the column length bytes.)CREATE TABLE該命令比較復(fù)雜。類似準(zhǔn)備創(chuàng)建數(shù)據(jù)庫一樣,有個(gè)樣本比較好。創(chuàng)建 table 中的存儲(chǔ)信息段The STORAGE clause specifies storage characteristics for the table. 其中 :Storage 信息View Code個(gè)人感覺創(chuàng)建 table 的時(shí)候, 不用特意指定storage, 因?yàn)樵?tablespace 中已經(jīng)指定了, 只要將他放在對(duì)應(yīng)的tablespace中就可以了我的感覺是對(duì)的.The STORAGE clause specifies storage characteristics for the table. The storage allocated for the first extent is 200K. When a second extent is required it will be created at 200K also defined by the NEXT value. When a third extent is required, it will be created at 200K because the PCTINCREASE has been set to 0. The maximum amount of extents that can be used is set at 5. with the minimum set to 1.PCTFREE 這個(gè)參數(shù)比較重要 ( 預(yù)留的空間,為了將來如果發(fā)生 update 等事務(wù)時(shí),這個(gè) block 還有空間可以使用, 如果這個(gè)值 ( 百分比)分配太小,那么當(dāng) update時(shí),如果空間不夠,就會(huì)發(fā)生將整個(gè) block 搬家的事件,如果分配的空間太大,那么又是一種浪費(fèi) )推薦 自動(dòng)管理。INITRANS : 控制同時(shí)能夠操作 那個(gè)塊的 transaction. Specifies the initial number of transaction entries allowcated within each data block allocated to the table. 范圍 1 255 , 默認(rèn)是 1. INITRANS ensures that a minimum number of concurrent transaction can update the block.In general , this value should not be changed from its default.創(chuàng)建表的原則:總的原則:減少資源競(jìng)爭(zhēng) Place tables in separate tablespaces. Use locally-managed tablespaces to avoid fragmentation(碎片化). Use few standard extent sizes for tables to reduce tablespace fragmentation.( 標(biāo)準(zhǔn)的 extent 就只有1種 )創(chuàng)建臨時(shí)表 temporary tablesTemporary tables can be created to hold session-private data that exists only for the duration of a transaction or session.查詢結(jié)果太大時(shí),臨時(shí)將結(jié)果緩存在磁盤上。CREATE GLOBAL TEMPORARY TABLE臨時(shí)表的數(shù)據(jù),只在一個(gè)事物或 session 中有效。對(duì)數(shù)據(jù)不需要做 DML 加鎖也可以創(chuàng)建 索引,視圖,觸發(fā)器。只有當(dāng)前的 session 可以看到相應(yīng)信息,visable, 即便是兩個(gè) session 使用的同一個(gè)臨時(shí)表,互相也看不到。一個(gè)用戶不可能阻止別的用戶訪問臨時(shí)表。即使 lock 臨時(shí)表也無法阻止別的用戶使用該表。臨時(shí)表也會(huì)產(chǎn)生 undo 和 redo 信息,但是很少?;究梢院雎?。用戶的臨時(shí)表是放在 自己臨時(shí)表空間中,A 和 B 都用一個(gè)臨時(shí)表,但是這個(gè)臨時(shí)表存儲(chǔ)在 2 個(gè)臨時(shí)表空間中。臨時(shí)表只是定義了一個(gè)表的摸板,但是這個(gè)表并不存在,并沒有產(chǎn)生真正的表空間。(沒有分配磁盤), 這是與實(shí)際表的區(qū)別。只是在運(yùn)行時(shí)刻,才臨時(shí)分配了一個(gè) segment.即 user1 用的時(shí)候,這個(gè)臨時(shí)表,分配了一個(gè)空間, temp1當(dāng) user2 用的時(shí)候,這個(gè)臨時(shí)表,又分配了 temp2, 所以,雖然是一個(gè)gloable temporary table, 但其實(shí)是2張表。on commit delete rows to specify that rows are only visible within the transactionon commit preserve rows to specify that rows are visibile for the entire sessionsession 有效 : 例子create global temporary table tmp_session on commitpreserverowsas select * from t where 1=0 ;transaction 有效 : 例子create global temporary table tmp_session on commitdeleterowsas select * from t where 1=0 ;提交事物后,session 級(jí)別的還會(huì)有數(shù)據(jù)存在,而 事物級(jí)別的數(shù)據(jù)就不存在了。當(dāng)該用戶退出后,session 斷了,那么 session 級(jí)別的數(shù)據(jù)也就沒有了。Manage storage structure in a table分析表 可以 得到 row size, 在性能調(diào)優(yōu)提到。Migration 移動(dòng) , 帶來的后果就是 oracle 的性能下降。 I/O 要翻一翻。應(yīng)該盡量避免 MigrationRow chaining如果一個(gè)條記錄中有太多列,或者列太長,oracle 就會(huì)把它分成不同的部分,每個(gè)部分是 row piece, 每塊里都包含指針,然后連接成一個(gè)完整記錄。也同樣加重了 oracle 讀取的負(fù)擔(dān)。檢測(cè)的 Migration, Row chaining , oracle 中有個(gè)包,可以提供分析的功能。dbms_metadata 包修改的內(nèi)容,只能作用于新的 block.限制 : The value of INITIAL cannot be modified for a table. The value of NEXT specified will be rounded to a value that is multiple of the block size greater than or equal to the value specified.以下情況,需要使用手工分配 額外空間??赡苄枰獙?duì)表的重新組織,類似磁盤碎片整理。將數(shù)據(jù) 移動(dòng)到另外的 segment中,保存 index, constraints, privilege 等信息。Is being used to move a table to a different tablespace or reorganize extentsAfter moving a table you will have to rebuild the indexes to avoid some error.truncate table前一章 有介紹過 高水位的問題,這點(diǎn)與 delete from table; 不一樣。DDLDrop tableDrop column不常使用,8i版本都沒有這個(gè)命令Dropping a column can be time consuming and require a large amount of undo space. While dropping columns from large tables, checkpoints can be specified to minimize the use of undo space.Using the UNUSED Option可以設(shè)置 column 為 unusedALTER TABLE hr.employees SET UNUSED COLUMN 列名 CASCADE CONSTRAINTSALTER TABLE hr.employees DROP UNUSED COLUMNS CHECKPOINT
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 體育產(chǎn)業(yè)市場(chǎng)營銷中的區(qū)域市場(chǎng)差異化策略考核試卷
- 儲(chǔ)存庫房照明與消防系統(tǒng)檢查考核試卷
- 品牌個(gè)性表達(dá)考核試卷
- 智能決策考核試卷
- 企業(yè)承包合同(14篇)
- 輕量化設(shè)計(jì)基礎(chǔ)
- 個(gè)人下半年工作總結(jié)12篇
- 大班健康《細(xì)菌家族》
- 水果拼盤活動(dòng)方案
- 森林戶外徒步活動(dòng)方案
- 數(shù)字化藝術(shù)-終結(jié)性考核-國開(SC)-參考資料
- 2025盤錦市興隆臺(tái)區(qū)輔警考試試卷真題
- 二年級(jí)口才與演講教案
- 2025年醫(yī)養(yǎng)結(jié)合養(yǎng)老服務(wù)項(xiàng)目可行性研究報(bào)告
- 學(xué)校規(guī)范常規(guī)化管理
- 小學(xué)數(shù)學(xué)教學(xué)案例分析 (一)
- 裝修公司掛靠協(xié)議書范本
- 《阿爾茨海默病的護(hù)理》課件
- 2025春季學(xué)期國開電大??啤度宋挠⒄Z1》一平臺(tái)在線形考(綜合測(cè)試)試題及答案
- 2025-2030中國水晶玻璃茶具行業(yè)市場(chǎng)發(fā)展現(xiàn)狀及競(jìng)爭(zhēng)格局與投資前景研究報(bào)告
- 電磁兼容(EMC)培訓(xùn)資料
評(píng)論
0/150
提交評(píng)論