午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    Oracle表空間管理
    來(lái)源:易賢網(wǎng) 閱讀:848 次 日期:2014-10-17 10:48:36
    溫馨提示:易賢網(wǎng)小編為您整理了“Oracle表空間管理”,方便廣大網(wǎng)友查閱!

    2 表空間

    Oracle磁盤(pán)管理中的最高邏輯層是表空間,Oracle11g中必須創(chuàng)建的4個(gè)表空間是SYSTEM, SYSAUX,TEMP, UNDOTBS1。

    2 SYSTEM:存儲(chǔ)數(shù)據(jù)字典等,pl/sql代碼等。

    2 SYSAUX:存儲(chǔ)與數(shù)據(jù)庫(kù)選項(xiàng)相關(guān)的數(shù)據(jù)

    2 TEMP:用于大的排序操作

    2 UNDUTBS1:為讀一致性和恢復(fù)的目的,存儲(chǔ)事務(wù)信息。

    表空間的下一層是段,一個(gè)段只能駐留在一個(gè)表空間中;一個(gè)或多個(gè)區(qū)可以組成一個(gè)段,每個(gè)區(qū)只能駐留在一個(gè)數(shù)據(jù)文件中;一組連續(xù)的數(shù)據(jù)塊可以組成一個(gè)區(qū)。如果要查詢表空間與對(duì)應(yīng)的數(shù)據(jù)文件的相關(guān)信息,可以從dba_data_files數(shù)據(jù)字典中查詢表空間及其包含的數(shù)據(jù)文件,舉例如下:

    SQL> col tablespace_name for a10;

    SQL> col file_name for a50;

    SQL> col bytes for 999,999,999;

    SQL>Select tablespace_name,file_name, bytes fromdba_data_files order by tablespace_name;

    1、 SYSTEM表空間

    SYSTEM表空間存放內(nèi)部數(shù)據(jù)和數(shù)據(jù)字典,主要存放SYS用戶的各個(gè)對(duì)象和其他用戶的少量對(duì)象。例如:查詢USERS表空間中存放的數(shù)據(jù)對(duì)象及其類型和擁有者。

    SQL>col owner for a10;

    SQL>col segment_name for a30;

    SQL>col segment_type for a20;

    SQL>select segment_type,segment_name,owner fromdba_segments where tablespace_name='USERS';

    2、 SYSAUX表空間

    SYSAUX表空間充當(dāng)SYSTEM表空間的輔助表空間,主要用于存儲(chǔ)除數(shù)據(jù)字典以外的其他數(shù)據(jù)對(duì)象。例如,查詢SYSAUX表空間所存放的用戶及其所擁有的對(duì)象數(shù)量:

    Select owner as 用戶, count(segment_name) as 對(duì)象數(shù)量 fromdba_segments where tablespace_name='SYSAUX' group by owner;

    3、 創(chuàng)建表空間

    創(chuàng)建表空間的語(yǔ)法如下:

    Create [smallfile | bigfile] tablespace tablespace_name

    Datafile '/path/filename' size num[k|m] reuse

    ['/path/filename' size num[k|m]reuse]

    [, …]

    [autoextend [on|off] next ] num[k|m]

    [maxsize [unlimited | num[k|m]]]

    [mininum extent num[k|m]]

    [default storage storage]

    [online | offline]

    [logging | nologging]

    [permanent | temporary]

    [extent management dictionary | local [autoallocate |uniform size num[k|m]]];

    說(shuō)明:

    ? smallfile | bigfile:表示創(chuàng)建的是小文件表空間還是大文件表空間

    ? autoextend [on|off] next:表示數(shù)據(jù)文件為自動(dòng)擴(kuò)展或非自動(dòng)擴(kuò)展,如為自動(dòng)擴(kuò)展則需要設(shè)置next的值。

    ? maxsize:表示數(shù)據(jù)文件自動(dòng)擴(kuò)展時(shí),允許數(shù)據(jù)文件擴(kuò)展的最大長(zhǎng)度字節(jié)數(shù),如果指定unlimited關(guān)鍵字,則不需要指定字節(jié)長(zhǎng)度。

    ? minimum extent:指出在表空間的extent的最小值,這個(gè)參數(shù)可以減少空間碎片,保證在表空間的extent是這個(gè)數(shù)值的整數(shù)倍。

    ? online | offline:創(chuàng)建表空間時(shí)可以指定為在線或離線。

    ? permanent | temporary:指定創(chuàng)建表空間是永久表空間或臨時(shí)表空間。默認(rèn)為永久表空間。

    ? logging | nologging:指定該表空間內(nèi)的表在加載數(shù)據(jù)時(shí)是否產(chǎn)生日志,默認(rèn)為產(chǎn)生日志,即使設(shè)定為nologging,但在進(jìn)行insert,update,delete操作時(shí),oracle仍會(huì)將信息記錄到redo log buffer中。

    ? extent management dictionary | local:指定表空間的擴(kuò)展方式是使用數(shù)據(jù)字典管理還是本地化管理。默認(rèn)為本地化管理。

    ? autoallocate | uniform size:如果采用本地化管理,在表空間擴(kuò)展時(shí),指定每次區(qū)的擴(kuò)展大小是系統(tǒng)自動(dòng)指定還是按照同等大小進(jìn)行。如果設(shè)定uniform關(guān)鍵字,默認(rèn)擴(kuò)展大小為1MB。

    ? reuse:表示如果該文件存在,則清除該文件再重建該文件;若文件不存在,則創(chuàng)建該文件。

    ? default storage:設(shè)定以后要?jiǎng)?chuàng)建的表、索引、簇的存儲(chǔ)參數(shù)值。

    4、 刪除表空間

    ? 刪除空的表空間,但是不包含物理文件

    drop tablespacetablespace_name;

    ? 刪除非空表空間,但是不包含物理文件

    drop tablespacetablespace_name including contents;

    ? 刪除空表空間,包含物理文件

    drop tablespace tablespace_nameincluding datafiles;

    ? 刪除非空表空間,包含物理文件

    drop tablespacetablespace_name including contents and datafiles;

    ? 如果其他表空間中的表有外鍵等約束關(guān)聯(lián)到了本表空間中的表的字段,就要加上CASCADECONSTRAINTS

    drop tablespacetablespace_name including contents and datafiles CASCADE CONSTRAINTS;

    5、 案例

    ? 創(chuàng)建表空間,然后刪除該表空間。

    Createtablespace exampletb

    Datafile 'E: examp01.dbf' size 5M autoextend on next 128k maxsize 1000m,

    'E: examp02.dbf' size 5Mautoextend on next 128k maxsize 1000m;

    說(shuō)明:以上例子創(chuàng)建的表空間由examp01.dbf和examp02.dbf兩個(gè)文件組成。創(chuàng)建完成后,可以發(fā)現(xiàn)在相應(yīng)路徑下增加了2個(gè)文件。

    drop tablespaceexampletb;

    ? 創(chuàng)建表空間和表,然后刪除該表空間。

    Createtablespace exampletb Datafile 'E: examp01.dbf'size 5M autoextendon next 128k maxsize 1000m reuse,

    'E:examp02.dbf' size 5Mautoextend on next 128k maxsize 1000m reuse;

    create tablescott.student

    (

    id number,

    name VARCHAR2(10)

    )tablespaceexampletb;

    說(shuō)明:向student表插入數(shù)據(jù)時(shí),數(shù)據(jù)將存儲(chǔ)在表空間exampletb中,而exampletb表空間擁有一個(gè)或多個(gè)數(shù)據(jù)文件,所以student數(shù)據(jù)最終存儲(chǔ)到examp01和examp02的數(shù)據(jù)文件中。

    drop tablespaceexampletb including contents;

    ? 創(chuàng)建表空間,然后刪除該表空間及數(shù)據(jù)文件。

    Create tablespaceexampletb

    Datafile 'E: examp01.dbf' size 5M autoextend on next 128k maxsize 1000mreuse,

    'E:examp02.dbf' size 5Mautoextend on next 128k maxsize 1000m reuse;

    drop tablespaceexampletb including datafiles;

    ? 創(chuàng)建表空間和表,然后刪除該表空間及數(shù)據(jù)文件。

    Createtablespace exampletb

    Datafile 'E: examp01.dbf' size 5M autoextend on next 128k maxsize 1000m,

    'E:examp02.dbf' size 5Mautoextend on next 128k maxsize 1000m;

    create tablescott.student

    (

    id number,

    name VARCHAR2(10)

    )tablespaceexampletb;

    drop tablespaceexampletb including contents and datafiles;

    說(shuō)明:如果drop tablespace語(yǔ)句中含有datafiles,那datafiles之前必須有contents關(guān)鍵字,不然會(huì)提示錯(cuò)誤。

    ? 創(chuàng)建兩個(gè)表空間,分別在其中創(chuàng)建主碼表和外碼表,然后刪除包含主碼表的表空間及數(shù)據(jù)文件。

    Createtablespace exampletb1

    Datafile 'E: examp03.dbf' size 5M autoextend on next 128k maxsize 1000m;

    Createtablespace exampletb2

    Datafile 'E: examp02.dbf' size 5M autoextend on next 128k maxsize 1000m;

    create tabletest1(mobile number(13) primary key)tablespace exampletb1;

    create table test2(mobile number(13) references test1(mobile)) tablespace exampletb2;

    drop tablespace exampletb1 including contents and datafiles cascade constraints;

    更多信息請(qǐng)查看IT技術(shù)專欄

    更多信息請(qǐng)查看數(shù)據(jù)庫(kù)
    易賢網(wǎng)手機(jī)網(wǎng)站地址:Oracle表空間管理
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2025國(guó)考·省考課程試聽(tīng)報(bào)名

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)