




已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
ObjectivesStoring User Data Regular tables Partitioned tables Index-organized tables Clustered tables普通表分區(qū)表 : 如果一個表太大了,那么就會在這個大表的基礎(chǔ)上,在分為子表,叫做 partition. 每個 row 是存儲在一起的,比如 有1000行數(shù)據(jù),可能 前 500 rows 存儲在一個 partition 里邊,后 500 rows 存儲在一個 partition里。每個分區(qū)是一個 segment, 并且可以存儲在不同的tablespace中。Index-organized tables : 這個“索引表” 不同于以往意義的索引,它是將存儲的數(shù)據(jù)本身按照某種順序進行了存儲,所以查詢效率很高。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 多個表,那么,可以將多個表存儲為集群,這樣在查詢時會提高效率。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ù)字型,文本型,日期型,二進制( LOB )盡量用 varchar2 , 不要使用 char, 除非是固定格式,比如性別,只有 男,女如果 oracle 內(nèi)部表的列數(shù)超過 254列,oracle 會將一行 分成幾塊來存儲。會加重 I/O 負荷。索引是依附于表的。對于任何一張表都有 ROWID,隱含的。select ROWID, ID, NAME from employee;ROWID 的內(nèi)容, 可以看到 ROWID 可以快速定位一條記錄的位置。Table Structure90% 一行放在一個 database block 中。( 一個 database block 中還可以放行 )列存儲的順序通常就是你定義的列的順序,并且如果某列的值是 NULL, 那么是不會存儲該列的。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 : 存儲列的長度,還有列的值。列的值是緊挨著列的長度信息。 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ù)庫一樣,有個樣本比較好。創(chuàng)建 table 中的存儲信息段The STORAGE clause specifies storage characteristics for the table. 其中 :Storage 信息View Code個人感覺創(chuàng)建 table 的時候, 不用特意指定storage, 因為在 tablespace 中已經(jīng)指定了, 只要將他放在對應(yīng)的tablespace中就可以了我的感覺是對的.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 這個參數(shù)比較重要 ( 預(yù)留的空間,為了將來如果發(fā)生 update 等事務(wù)時,這個 block 還有空間可以使用, 如果這個值 ( 百分比)分配太小,那么當(dāng) update時,如果空間不夠,就會發(fā)生將整個 block 搬家的事件,如果分配的空間太大,那么又是一種浪費 )推薦 自動管理。INITRANS : 控制同時能夠操作 那個塊的 transaction. Specifies the initial number of transaction entries allowcated within each data block allocated to the table. 范圍 1 255 , 默認是 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)建表的原則:總的原則:減少資源競爭 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)建臨時表 temporary tablesTemporary tables can be created to hold session-private data that exists only for the duration of a transaction or session.查詢結(jié)果太大時,臨時將結(jié)果緩存在磁盤上。CREATE GLOBAL TEMPORARY TABLE臨時表的數(shù)據(jù),只在一個事物或 session 中有效。對數(shù)據(jù)不需要做 DML 加鎖也可以創(chuàng)建 索引,視圖,觸發(fā)器。只有當(dāng)前的 session 可以看到相應(yīng)信息,visable, 即便是兩個 session 使用的同一個臨時表,互相也看不到。一個用戶不可能阻止別的用戶訪問臨時表。即使 lock 臨時表也無法阻止別的用戶使用該表。臨時表也會產(chǎn)生 undo 和 redo 信息,但是很少。基本可以忽略。用戶的臨時表是放在 自己臨時表空間中,A 和 B 都用一個臨時表,但是這個臨時表存儲在 2 個臨時表空間中。臨時表只是定義了一個表的摸板,但是這個表并不存在,并沒有產(chǎn)生真正的表空間。(沒有分配磁盤), 這是與實際表的區(qū)別。只是在運行時刻,才臨時分配了一個 segment.即 user1 用的時候,這個臨時表,分配了一個空間, temp1當(dāng) user2 用的時候,這個臨時表,又分配了 temp2, 所以,雖然是一個gloable temporary table, 但其實是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 級別的還會有數(shù)據(jù)存在,而 事物級別的數(shù)據(jù)就不存在了。當(dāng)該用戶退出后,session 斷了,那么 session 級別的數(shù)據(jù)也就沒有了。Manage storage structure in a table分析表 可以 得到 row size, 在性能調(diào)優(yōu)提到。Migration 移動 , 帶來的后果就是 oracle 的性能下降。 I/O 要翻一翻。應(yīng)該盡量避免 MigrationRow chaining如果一個條記錄中有太多列,或者列太長,oracle 就會把它分成不同的部分,每個部分是 row piece, 每塊里都包含指針,然后連接成一個完整記錄。也同樣加重了 oracle 讀取的負擔(dān)。檢測的 Migration, Row chaining , oracle 中有個包,可以提供分析的功能。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.以下情況,需要使用手工分配 額外空間。可能需要對表的重新組織,類似磁盤碎片整理。將數(shù)據(jù) 移動到另外的 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前一章 有介紹過 高水位的問題,這點與 delete from table; 不一樣。DDLDrop tableDrop column不常使用,8i版本都沒有這個命令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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 飯圈組合協(xié)議書
- 普惠托育服務(wù)發(fā)展路徑與創(chuàng)新策略
- 經(jīng)濟合作與國際關(guān)系的交集分析試題及答案
- 行政法學(xué)未來展望試題及答案
- 法學(xué)概論學(xué)習(xí)中的時間管理與計劃制定試題及答案
- 不同市場下的2025年公司戰(zhàn)略及試題及答案
- 軟件生命周期管理試題及答案
- 金融市場與政治經(jīng)濟學(xué)的相互影響試題及答案
- 行政法學(xué)中的爭議熱點及試題與答案
- 計算機考試實務(wù)技巧分享試題及答案
- 喝酒受傷賠償協(xié)議書模板
- 2025年廣東廣州市高三二模高考英語試卷試題(含答案詳解)
- 2025年中國公務(wù)車行業(yè)市場深度評估及投資策略咨詢報告
- 鐵路客運安檢員應(yīng)知應(yīng)會考試題庫300題(含答案)
- 雕像遷移 施工方案
- 2025年湖北省新華書店(集團)有限公司招聘筆試參考題庫含答案解析
- 燃氣公司新員工入職三級安全教育培訓(xùn)
- 黑龍江商業(yè)職業(yè)學(xué)院《生活中的科學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 2025年中國鐵路沈陽局集團有限公司招聘筆試參考題庫含答案解析
- 水泥攪拌樁培訓(xùn)
- 電網(wǎng)工程設(shè)備材料信息參考價(2024年第四季度)
評論
0/150
提交評論