欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Oracle表空間和數(shù)據(jù)文件

【基礎(chǔ)】Oracle 表空間和數(shù)據(jù)文件

多個表空間的優(yōu)勢:
1.能夠?qū)?shù)據(jù)字典與用戶數(shù)據(jù)分離出來,避免由于字典對象和用戶對象保存在同一個數(shù)據(jù)文件中而產(chǎn)生的I/O沖突
2.能夠?qū)⒒赝藬?shù)據(jù)與用戶數(shù)據(jù)分離出來,避免由于硬盤損壞而導(dǎo)致永久性的數(shù)據(jù)丟失
3.能夠?qū)⒈砜臻g的數(shù)據(jù)文件分散保存到不同的硬盤上,平均分布物理I/O操作
4.能夠?qū)⒛硞€表空間設(shè)置為脫機狀態(tài)或聯(lián)機狀態(tài),以便對數(shù)據(jù)庫的一部分進行備份和恢復(fù)
5.能夠?qū)⒛硞€表空間設(shè)置為只讀狀態(tài),從而將數(shù)據(jù)庫的一部分設(shè)置為只讀狀態(tài)
6.能夠為某種特殊用途專門設(shè)置一個表空間,比如臨時表空間等,以優(yōu)化表空間的使用效率
7.能夠更佳靈活的為用戶設(shè)置表空間限額

創(chuàng)新互聯(lián)服務(wù)項目包括金安網(wǎng)站建設(shè)、金安網(wǎng)站制作、金安網(wǎng)頁制作以及金安網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,金安網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到金安省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

 

SYSTEM表空間內(nèi)存儲:
1.數(shù)據(jù)庫的數(shù)據(jù)字典
2.所有PL/SQL程序的源代碼和解析代碼
3.數(shù)據(jù)庫對象的定義

(所有表空間的數(shù)據(jù)文件總和不能超過創(chuàng)建數(shù)據(jù)庫時指定的maxdatafiles參數(shù)的限制)

 

本地管理表空間:
1.在存儲分配過程中不需要訪問數(shù)據(jù)庫,可以提高存儲分配操作的速度
2.能夠避免在表空間的存儲管理操作中產(chǎn)生的遞歸現(xiàn)象
3.不會產(chǎn)生重做和撤銷記錄
4.簡化DBA對表空間的管理操作
5.降低用戶對數(shù)據(jù)字典的依賴性

 

字典管理方式的表空間:
表空間中所有存儲空間的管理信息都保存在數(shù)據(jù)字典中,在進行存儲空間管理時會產(chǎn)生回退和重做記錄

本地管理方式的表空間:
表空間中所有存儲空間的管理信息都保存在數(shù)據(jù)文件頭部的位圖中

(在9i中創(chuàng)建表空間默認就是本地管理方式.8i以前的版本,只能用字典管理方式的表空間.)

 


創(chuàng)建表空間(字典管理方式)
create tablespace dmusertbs
datafile 'i:\oracle\oradata\dmusertbs.dbf' size 50M
extent management dictionary;

多個數(shù)據(jù)文件(字典 管理方式 )
create tablespace dmusertbs
datafile 'i:\oracle\oradata\dmusertbs01.dbf' size 50M,
         'i:\oracle\oradata\dmusertbs02.dbf' size 50M,
         'i:\oracle\oradata\dmusertbs03.dbf' size 50M
extent management dictionary;

指定默認存儲參數(shù)(字典管理方式)
create tablespace dmusertbs
datafile 'i:\oracle\oradata\dmusertbs.dbf' size 50M
default storage(
   initial 256K
   next 256K
   minextents 2
   pctincrease 0
   maxextents 4096)
minimum extent 128K
logging
online
permanent
extent management dictionary;

創(chuàng)建表空間(本地管理方式)

1 .create tablespace lmusertbs
  datafile 'i:\oracle\oradata\lmusertbs.dbf' size 50M
  extent management local autoallocate;
  (oracle對區(qū)的分配進行自動管理,這是默認的設(shè)置,在autoallocate方式下, 表空間中最小的區(qū)為64K)

2 .create tablespace lmusertbs
  datafile 'i:\oracle\oradata\lmusertbs.dbf' size 50M
  extent management local uniform size 512K;
  (所有的區(qū)必須具有統(tǒng)一的大小,Uniform方式帶來的最大優(yōu)點是在表空間中不會產(chǎn)生任何存儲碎片,
   如果在uniform關(guān)鍵字后面沒有指定size參數(shù)的值,SIZE參數(shù)將使用1MB做為默認值)

3. create tablespace lmusertbs
  datafile 'i:\oracle\oradata\lmusertbs.dbf' size 50M
  extent management local uniform size 512K
  segment space management auto;
  (具有自動段存儲管理方式的表空間)

創(chuàng)建臨時表空間(字典管理方式)
一個臨時表空間可以被多個數(shù)據(jù)庫用戶共享, oracle只會為一個實例創(chuàng)建一個臨時段,這個臨時段被實例中所有的排序操作共享使用,但是臨時段中的每一個區(qū)只能由一個事務(wù)使用.臨時段在數(shù)據(jù)庫啟動后執(zhí)行第一次排序操作時被創(chuàng)建.

注意 :字典管理方式的臨時表空間可以象普通表空間那樣使用 alter tablespace 來進行更改
建議將initial和next參數(shù)設(shè)置成相同的值,并且應(yīng)當是初始化參數(shù)sort_area_size和db_block_size
兩個值之和的整數(shù)倍,pctincrease參數(shù)應(yīng)當設(shè)置成0
create tablespace usertemp
datafile 'i:\oracle\oradata\sort01.dbf' size 50M
extent management dictionary
default storage(
  initial 192K
  next 192K
  minextents 1
  pctincrease 0)
temporary;

創(chuàng)建臨時表空間(本地管理方式,區(qū)的分配管理方式只能是uniform)
(在Oracle 9i中,強烈建議使用本地管理方式的臨時表空間來代替字典管理方式的臨時表空間)

create temporary tablespace lmtemp
 tempfile 'i:\oracle\oradata\lmtemp01.dbf' size 50M
 extent management local  uniform  size 136K
 (必須使用tempfile子句,tempfile為臨時數(shù)據(jù)文件,與普通數(shù)據(jù)文件相比,臨時數(shù)據(jù)文件不能用alter database來創(chuàng)建)

對于本地管理方式的臨時表空間,alter tablespace語句的作用僅僅是為臨時表空間添加新的臨時文件.
增加新的臨 時文件
alter tablespace lmtemp
 add tempfile 'i:\oracle\oradata\lmtemp02.dbf' size 50M
(對于本地管理方式的表空間,alter tablespace語句的作用僅僅是為臨時表空間添加新的臨時文件,而不能對臨時表空間進行其它任何修改)

 

表空間的管理主要包括修改默認存儲參數(shù),手工合并碎片,設(shè)置表空間的可用性等幾個方面。盡量讓表空間使用較少的數(shù)據(jù)文件,因為在某些操作系統(tǒng)中對一個進程可以同時打開的系統(tǒng)文件數(shù)量進行限制,由此會影響到同時處于聯(lián)機狀態(tài)的表空間數(shù)量。

修改表空間的默認存儲參數(shù)
alter tablespace duusertbs
default storage(
  next 128K
  maxextents unlimited
  pctincrease 20);
(表空間創(chuàng)建之后不能對 initial minextents 參數(shù)進行修改)

 

如果表空間的默認存儲參數(shù) pctincrease不為0 ,oracle將定期啟動SMON后臺進程,合并表空間相鄰的存儲碎片,
如果 pctincrease是0 ,SMON進程不會執(zhí)行合并操作.
如果表空間中所有的區(qū)都具有相同的大小,則不需要手工合并存儲碎片.

本地管理方式的表空間不需要進行存儲碎片的合并操作,因為oracle會自動利用位圖自動合并.
只需要在字典管理方式的表空間中 手工合并存儲碎片.

alter tablespace dmusertbs coalesce
(如果使用了coalesce子句,則不能在使用其它任何子句)

利用下面的查詢可以看到表空間users中存在哪些存儲碎片
SQL> select block_id,bytes,blocks
  2  from dba_free_space
  3  where tablespace_name='users'
  4  order by block_id;

改變表空間的 可用性:

1. alter tablespace user01 offline normal (正常方式)
oracle會執(zhí)行一次檢查點,將SGA區(qū)中與該表空間相關(guān)的臟緩存塊都寫入數(shù)據(jù)文件中,然后再關(guān)閉表空間對應(yīng)的數(shù)據(jù)文件,下一次將表空間?;謴?fù)為聯(lián)機狀態(tài)時,不需要進行數(shù)據(jù)庫恢復(fù).

2. alter tablespace user01 offline temporary( 臨時方式)
oracle執(zhí)行檢查點的時候并不會檢查各個數(shù)據(jù)文件的狀態(tài),即使某些數(shù)據(jù)文件不可用,oracle也會忽視這些錯誤,下一次將表空間恢復(fù)為聯(lián)機狀態(tài)時,可能需要進行數(shù)據(jù)庫恢復(fù).如果數(shù)據(jù)文件可用,oracle會將與該表空間相關(guān)的臟緩存塊都寫入數(shù)據(jù)文件中.

3. alter tablespace user01 offline immediate (立即方式)
oracle不會執(zhí)行檢查點,也不會檢查各個數(shù)據(jù)文件的狀態(tài),而是直接將屬于表空間的數(shù)據(jù)文件設(shè)置成脫機狀態(tài),下一次將表空間恢復(fù)為聯(lián)機狀態(tài)時,需要進行數(shù)據(jù)庫恢復(fù).運行在noarchivelog方式下的數(shù)據(jù)庫不允許用這種方式切換到脫機狀態(tài).

恢復(fù)表空間為聯(lián)機狀態(tài)
alter tablespace user01 online;

設(shè)置表空間為只讀狀態(tài)
alter tablespace user01 read only

設(shè)置表空間為讀寫狀態(tài)
alter tablespace user01 read write

刪除表空間(不包括對應(yīng)的數(shù)據(jù)文件)
drop tablespace users including contents;

刪除表空間(包括對應(yīng)的數(shù)據(jù)文件)
drop tablespace users including contents and datafiles;

表空間數(shù)據(jù)字典
v$tablespace 控制文件中獲取的表空間的名稱和編號信息
v$datafile 控制文件中獲取的數(shù)據(jù)文件的名稱和編號信息
v$tempfile 所有臨時數(shù)據(jù)文件的基本信息
v$sort_segment 實例所創(chuàng)建的排序區(qū)的信息
v$sort_user 排序區(qū)的用戶使用情況信息
dba_tablespaces 數(shù)據(jù)庫中表空間的名稱和編號信息
dba_segments 表空間中段的信息
dba_extents 表空間中區(qū)的信息
dba_free_space 表空間中空閑區(qū)的信息
dba_data_files 數(shù)據(jù)文件亦即所屬表空間的信息
dba_temp_files 臨時數(shù)據(jù)文件亦即所屬表空間的信息

 


包括為表空間添加新的數(shù)據(jù)文件,更改已有數(shù)據(jù)文件的大小,名稱或者位置。初始化參數(shù)db_files指定在SGA區(qū)中能夠保存的數(shù)據(jù)文件信息的最大數(shù)量,也就是一個實例所能支持的數(shù)據(jù)文件的最大數(shù)量,能夠在實例運行過程中修改它.

1. 創(chuàng)建表空間lmusertbs時將數(shù)據(jù)文件設(shè)置為自動增長方式
create tablespace lmusertbs
  datafile 'i:\oracle\oradata\lmusertbs01.dbf' size 50M
  autoextend on
  next 5M
  maxsize 500M
  extent management local;
(next參數(shù)指定每次自動增長的大小,maxsize為數(shù)據(jù)文件的最大大小)

2. 在表空間lmusertbs上添加一個自動增長方式的數(shù)據(jù)文件
alter tablespace lmusertbs
  add datafile 'i:\oracle\oradata\lmusertbs02.dbf' size 50M
  autoextend on
  next 5M
  maxsize 500M;

3.如果數(shù)據(jù)文件已經(jīng)創(chuàng)建,將它設(shè)置成自動增長方式
alter database
  datafile 'i:\oracle\oradata\dmusertbs01.dbf'
  autoextend on
  next 5M
  maxsize 500M;

4.取消已有數(shù)據(jù)文件的自動增長方式
alter database
  datafile 'i:\oracle\oradata\dmusertbs01.dbf'
  autoextend off;

5.手工改變數(shù)據(jù)文件的大小:

將數(shù)據(jù)文件dmusertbs01.dbf增大為500MB

alter database datafile 'i:\oracle\oradata\dmusertbs01.dbf' resize 500M;

單獨改變數(shù)據(jù)文件的可用性(數(shù)據(jù)庫運行在歸檔模式下):
alter database datafile 'i:\oracle\oradata\dmusertbs01.dbf' online;(聯(lián)機狀態(tài))
alter database datafile 'i:\oracle\oradata\dmusertbs01.dbf' offline;(脫機狀態(tài))

單獨改變數(shù)據(jù)文件的可用性(數(shù)據(jù)庫運行在不歸檔模式下):
alter database datafile '/u02/oracle/oradata/user01.dbf' offline drop;
用offline drop可以確保使數(shù)據(jù)文件脫機時立即丟掉

6.改變數(shù)據(jù)文件的名稱和位置:
A.要改變的數(shù)據(jù)文件屬于同一個表空間

1.將包含數(shù)據(jù)文件的表空間設(shè)置為脫機狀態(tài)
       alter tablespace users offline normal

2.在操作系統(tǒng)中重新命名或者移動數(shù)據(jù)文件

3.在數(shù)據(jù)庫內(nèi)部修改數(shù)據(jù)文件的名稱或者位置(用alter tablespace ... rename datafile子句,to子句后的數(shù)據(jù)文件必須存在)
改變名稱:
alter tablespace users
  rename datafile
    'i:\oracle\oradata\user01.dbf',
    'i:\oracle\oradata\user02.dbf'
  to
    'i:\oracle\oradata\lmuser01.dbf',
    'i:\oracle\oradata\lmuser02.dbf';

改變位置:
alter tablespace users
  rename datafile
    'i:\oracle\oradata\user01.dbf',
    'i:\oracle\oradata\user02.dbf'
  to
    ' h :\oracle\oradata\user01.dbf',
    ' h :\oracle\oradata\user02.dbf';

4.重新將表空間設(shè)置為聯(lián)機狀態(tài)
alter tablespace users online

5.備份控制文件

B.要改變的數(shù)據(jù)文件屬于多個表空間
1.關(guān)閉數(shù)據(jù)庫
2.在操作系統(tǒng)中重新命名或者移動數(shù)據(jù)文件
3.加載數(shù)據(jù)庫,startup mount
4.在數(shù)據(jù)庫內(nèi)部修改數(shù)據(jù)文件的名稱或者位置(用alter database ... rename file子句,to子句后的數(shù)據(jù)文件必須存在)
alter database
  rename file
    'i:\oracle\oradata\user01.dbf',
    'i:\oracle\oradata\temp01.dbf'
  to
    'i:\oracle\oradata\lmuser01.dbf',
    'i:\oracle\oradata\lmtemp01.dbf';

5.alter database open;
6.備份控制文件


數(shù)據(jù)文件數(shù)據(jù)字典
DBA_DATA_FILES 數(shù)據(jù)庫中所有數(shù)據(jù)文件的信息
DBA_TEMP_FILES 數(shù)據(jù)庫中所有臨時數(shù)據(jù)文件的信息
DBA_EXTENTS 表空間中已分配的區(qū)的描述信息,包括區(qū)所屬的數(shù)據(jù)文件的編號
DBA_FREE_SPACE 表空間中空閑區(qū)的信息

刪除表空間的數(shù)據(jù)文件
(適用情況:不小心給一個表空間增加了一個數(shù)據(jù)文件,或者你把文件大小設(shè)得過大,所以想把它刪掉)

(注:Oracle不提供如刪除表。視圖一樣刪除數(shù)據(jù)文件的方法,數(shù)據(jù)文件是表空間的一部分,所以不能“移走”表空間。
 在對表空間/數(shù)據(jù)文件進行任何脫機、刪除之前,首先對數(shù)據(jù)庫進行一個全備份)

A: 如果數(shù)據(jù)文件是所在表空間的唯一的數(shù)據(jù)文件,你只要簡單地刪除表空間即可:
DROP TABLESPACE <tablespace name> INCLUDING CONTENTS

B: 如果你的表空間有多個數(shù)據(jù)文件,而你不需要表空間中的內(nèi)容,或者你可以很容易重新產(chǎn)生表空間的內(nèi)容,你可以使用
DROP TABLESPACE <tablespace name> INCLUDING CONTENTS;命令來從Oracle數(shù)據(jù)字典刪除表空間、數(shù)據(jù)文件和表空間的內(nèi)容。Oracle不會再訪問該表空間中的任何內(nèi)容。然后重新創(chuàng)建表空間并重新導(dǎo)入數(shù)據(jù)。

C: 如果你的表空間有多個數(shù)據(jù)文件,而你還需保留該表空間中的其它數(shù)據(jù)文件中的內(nèi)容,則你必須首先export出該表空間中的所有內(nèi)容。為了確定表空間中包含那些內(nèi)容,運行:
select owner,segment_name,segment_type
from dba_segments
where tablespace_name='<name of tablespace>'

export出你想保留的內(nèi)容。如果export結(jié)束,你可以使用DROP TABLESPACE tablespace INCLUDING CONTENTS. ,這樣永久刪除表空間的內(nèi)容,使用操作系統(tǒng)命令物理刪除數(shù)據(jù)文件,按所需數(shù)據(jù)文件重新創(chuàng)建表空間,把數(shù)據(jù)import至表空間。

注意:

ALTER DATABASE DATAFILE <datafile name> OFFLINE DROP命令不能允許你刪除數(shù)據(jù)文件,它的目的是脫機該數(shù)據(jù)文件以刪除表空間。如果在歸檔模式下,使用ALTER DATABASE DATAFILE <datafile name> OFFLINE DROP來代替OFFLINE DROP。一旦數(shù)據(jù)文件脫機,Oracle不會再訪問該數(shù)據(jù)文件的內(nèi)容,但它仍然是表空間的一部分。這個數(shù)據(jù)文件在控制文件中標記OFFLINE,在數(shù)據(jù)庫啟動時不會對它與控制文件進行SCN的比較。在控制文件中保留這個數(shù)據(jù)文件的入口是方便以后的恢復(fù)。

如果你不想按照上述方法來刪除表空間,還有其它一些解決方法。

1.如果你想刪除數(shù)據(jù)文件的原因是因為分配了不合適的文件大小,你可以考慮RESIZE命令。
2.如果你不小心增加了一個數(shù)據(jù)文件,而這個文件還沒有分配空間,你可以使用

ALTER DATABASE DATAFILE <filename> RESIZE;命令使其小于5個 Oracle塊大小,如果數(shù)據(jù)文件的大小小于這個,Oracle將不會進行擴展數(shù)據(jù)文件。在以后,Oracle可以重建的時候來剔除這個不正確的文件。

---------------------------------------------------------------------------------------
<例子>
Question:

比如我的uses tablespace 有2個數(shù)據(jù)文件:users01.dbf 和 users02.dbf ,(數(shù)據(jù)庫為非歸檔模式)假如我執(zhí)行
alter tablespace users offline;
alter database datafile users02.dbf offline drop;
這時如果我在操作系統(tǒng)級別上刪除users02.dbf,下次重啟時會提示丟失文件,
我估計此命令只是在controlfile 級別做了修改,但dictionary中還是記錄有這個文件,請問如何完全刪除表空間中的一個數(shù)據(jù)文件?

ASK:
在noarchivelog mode, alter database datafile ...offline drop;
必須加上drop 選項,但是drop選項,并不從database 移除datafile。為了drop datafile, 你必須刪除datafile所在的表空間。用drop選項,datafile任然保留在數(shù)據(jù)字典中,狀態(tài)為recover 或者offline。
 
alter database datafile ...offline drop;
一旦數(shù)據(jù)文件offline,oracle不再訪問那個datafile,但是它still是那個表空間的一部分。datafile在controlfile中被標記為offline,在startup的時候,在controlfile和datafile之間并沒有對scn 做比較(這也運行你startup數(shù)據(jù)庫,伴隨一個不關(guān)鍵的datafile丟失)。datafile并沒有從controlfile上刪除,從而給你recover the datafile。
 
如果你真的想刪除user02.dbf, 你可以用transport tablespace特性,或者導(dǎo)出你想要保存的在user tablespace空間的object, 重新建立一個new tablespace

If you do not wish to follow any of these procedures, there are other things 
that can be done besides dropping the tablespace.
 
If the reason you wanted to drop the file is because you mistakenly created 
the file of the wrong size, then consider using the RESIZE command.  
 
If you really added the datafile by mistake, and Oracle has not yet allocated  any space within this datafile, then you can use ALTER DATABASE DATAFILE <filename> RESIZE; command to make the file smaller than 5 Oracle  blocks.  If the datafile is resized to smaller than 5 oracle blocks, then it will never be considered for extent allocation. At some later date, the tablespace can be
rebuilt to exclude the incorrect datafile.

本文名稱:Oracle表空間和數(shù)據(jù)文件
文章位置:http://chinadenli.net/article14/jgghge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計公司、域名注冊、網(wǎng)頁設(shè)計公司、網(wǎng)站收錄搜索引擎優(yōu)化、網(wǎng)站導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名
国产小青蛙全集免费看| 99久久国产亚洲综合精品| 国产一级一片内射视频在线| 欧美色婷婷综合狠狠爱| 欧美一级片日韩一级片 | 国内精品一区二区欧美| 激情综合网俺也狠狠地| 91国内视频一区二区三区| 国产一区二区不卡在线播放| 91日韩欧美中文字幕| 日韩人妻中文字幕精品| 日韩高清中文字幕亚洲| 亚洲夫妻性生活免费视频| 国产免费自拍黄片免费看| 真实偷拍一区二区免费视频| 成人精品视频在线观看不卡| 亚洲精品深夜福利视频| 国产精品成人一区二区三区夜夜夜 | 欧美日韩免费观看视频| 欧美人禽色视频免费看| 白丝美女被插入视频在线观看| 亚洲中文字幕高清乱码毛片| 国产一区二区在线免费| 欧美国产亚洲一区二区三区| 日韩欧美一区二区黄色| 尤物久久91欧美人禽亚洲| 亚洲欧美日韩中文字幕二欧美| 超薄肉色丝袜脚一区二区| 国产精品久久香蕉国产线| 精品国产亚洲一区二区三区| 中文字幕久久精品亚洲乱码| 99精品国产一区二区青青| 美女极度色诱视频在线观看| 国产无摭挡又爽又色又刺激| 丁香六月婷婷基地伊人| 国内午夜精品视频在线观看| 色婷婷在线视频免费播放| 日韩毛片视频免费观看| 欧美一级特黄特色大色大片| 亚洲国产四季欧美一区| 91精品国产av一区二区|