---------------------------------------------- -表空間的操作----------------------------------------------------
1.創(chuàng)建表空間:
create tablespace tablespace_name datafile 'filepath' size filesize autoextend on next autosize maxsize filemaxsize [unlimited]
eg:
create tablespace sales datafile 'c:\1.txt' size 10m autoextend on next 1m maxsize 100m
2.為表空間增加數(shù)據(jù)文件:
alter tablespace tablespace_name add datafile 'filepath' size filesize autoextend on next autosize maxsize filemaxsize[unlimited]
eg:
alter tablespace sales datafile 'c:\2.txt' size 10m autoextend on next 1m maxsize unlimited
3.調(diào)整表空間:
alter database datafile 'filepath' resize filesize--重置表空間的大小
eg:
alter database datafile 'c:\2.txt' resize 10m
4.關(guān)閉表空間的自動擴展屬性:
alter database datafile 'filepath' autoextend off
eg:
alter database datafile 'c:\2.txt' autoextend off
5.打開表空間的自動擴展屬性:
alter database datafile 'filepath' autoextend on
eg:
alter database datafile 'c:\2.txt' autoextend on
6.使表空間脫機:
alter tablespace tablespace_name offline
7.使表空間聯(lián)機:
alter tablespace tablespace_name online
8.設(shè)置表空間為只讀:
alter tablespace tablespace_name read only
9.設(shè)置表空間為讀寫:
alter tablespace tablespace_name read write
11.刪除表空間:
drop tablespace tablespace_name
12.刪除表空間的同時,刪除數(shù)據(jù)文件
drop tablespace tablespace_name including contents and datefiles
13.查看每個表空間占用空間的大?。?/span>
select tablespace_name,sum(bytes)/1024/1024 from dba_segments group by tablespace_name
10.移動表空間數(shù)據(jù)文件步驟:
a.使表空間脫機:alter tablespace tablespace_name offline
b.物理移動數(shù)據(jù)文件到目的地(可以是表空間的部分?jǐn)?shù)據(jù)文件或者是修改數(shù)據(jù)文件的名稱)
c.邏輯移動:alter tablespace tablespace_name rename datafile '源文件地址'to '目的文件地址'--注意可以將多個源文件轉(zhuǎn)移到同一個目的文件地址(多個源文件地址用逗號分隔)
d.將表空間聯(lián)機:alter tablespace tablespace_name online
11.查詢表空間的信息:
select tablespace_name,bytes/1024/1024 file_size_mb,file_name from DBA_DATE_FILES--注意書籍庫中的實體都是以大寫表示
12.當(dāng)數(shù)據(jù)文件被刪除的時候,如果對該數(shù)據(jù)文件操作的時候,oracle會報不能找到該數(shù)據(jù)文件的錯誤。如何處理。
(1)shutdown—關(guān)閉oracle實例
(2)startup --開啟oracle實例并打開數(shù)據(jù)庫
(3)alter database datafile ‘datafile_name’ offline drop;
(4)alter database open
------------------------------------------------------------------------------------------------------------------