Oracle入门(七)之表空间
表空間
????表空間是數(shù)據(jù)庫的邏輯劃分,一個(gè)表空間只能屬于一個(gè)數(shù)據(jù)庫。所有的數(shù)據(jù)庫對(duì)象都存放在指定的表空間中。但主要存放的是表, 所以稱作表空間。
????Oracle數(shù)據(jù)庫中至少存在一個(gè)表空間,即SYSTEM的表空間。
(1)創(chuàng)建表空間
語法:
create? ?tablespace? ?表空間名? ?datafile/tempfile? 文件路徑? ?[size? 文件大小]? ? [autoextend on next? 新增文件大小]? ?[maxsize? 最大文件大小];
(2)調(diào)整表空間
a.添加數(shù)據(jù)文件
alter tablespace tptest add datafile 'd:/tptest02.dbf' size 10m;b.改變數(shù)據(jù)文件大小
alter tablespace?datafile ‘*.dbf’ autoextend on next??20M maxsize 1000M;c.刪除數(shù)據(jù)文件
alter tablespace tablespace_name drop datafile file_name;
(3)查詢表空間
a.根據(jù)默認(rèn)視圖查詢
select name from v$tablespace;
b.根據(jù)數(shù)據(jù)文件查詢表空間
select? file_name,tablespace_name?from dba_data_files order by tablespace_name;
c.統(tǒng)計(jì)數(shù)據(jù)文件使用率
select b.file_name 物理文件名, b.tablespace_name 表空間, b.bytes/1024/1024 大小M, (b.bytes - sum(nvl(a.bytes,0))) / 1024 / 1024 已使用M, substr((b.bytes - sum(nvl(a.bytes, 0))) / (b.bytes) * 100, 1, 5) 利用率 from dba_free_space a, dba_data_files b where a.file_id = b.file_id group by b.tablespace_name, b.file_name, b.bytes order by b.tablespace_name;(4)刪除表空間
drop tablespace tpname including contents and datafiles;
? ? ? ? 注:oracle表空間刪除數(shù)據(jù)文件未刪除
(5)表空間只讀
alter tablespace? tpname READ ONLY
(6)表空間離線在線
alter tablespace tpname OFFLINE/ONLINE
(7)表空間文件離線刪除
alter tablespace tpname datafile 'tpname.dbf' offline drop;總結(jié)
以上是生活随笔為你收集整理的Oracle入门(七)之表空间的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Oracle入门(七B)之表空间删除数据
- 下一篇: 玩游戏的电脑要什么配件好?