Oracle基礎 01 表空間 tablespace
--檢視錶空間
select * from dba_tablespaces;
select * from v$tablespace;
select * from dba_data_files; --檢視資料檔案
select * from v$datafile;
select * from dba_temp_files; --檢視臨時檔案
select * from v$tempfile;
--查預設表空間和臨時表空間
select * from database_properties
where property_name like '%TABLESPACE';
alter user scott default tablespace emp; --修改soctt預設表空間為emp
grant unlimited tablespace to scott; --授予scott表空間操縱許可權
--建立表空間emp
create tablespace emp
datafile '/u01/app/oracle/db/emp01.dbf' size 50m autoextend on next 10m maxsize unlimited;
--表空間組
select * from dba_tablespace_groups; --檢視錶空間組
alter tablespace tmp01 tablespace group group1; --將臨時表空間tmp01新增到表空間組group1
alter tablespace tmp02 tablespace group ''; --將臨時表空間tmp02從表空間組group1中刪除
--表空間離線、線上
alter tablespace emp offline normal; --表空間歸檔模式離線
alter tablespace emp offline normal for drop; --表空間非歸檔模式離線(慎用)
alter tablespace emp online; --表空間線上
--重新命名錶空間
alter tablespace tsname1 rename to tsname2; --表空間重新命名tsname1 成tsname2
--刪除表空間
drop tablespace emp including contents and datafiles; --刪除表空間和資料檔案
--資料檔案的移動
alter tablespace emp offline normal; --先將表空間離線
mv /u01/app/oracle/oradata/dbtest/emp_data.dbf /u01/app/oracle/datafile/ --再移動資料檔案到指定目錄(linux下)
alter tablespace emp rename datafile'/u01/app/oracle/oradata/dbtest/emp_data.dbf'
to '/u01/app/oracle/datafile/yd03_data.dbf'; --修改控制檔案資訊
alter tablespace emp online; --再將表空間上線
--增加資料檔案
alter tablespace emp add datafile '/u01/app/oracle/oradata/emp02.dbf'
size 10m;
--增大資料檔案
alter database datafile '/u01/app/oracle/oradata/emp01.dbf' resize 50m;
--刪除資料檔案
alter tablespace emp drop datafile '/u01/app/oracle/emp02.dbf';
--關閉資料檔案自動擴充套件
alter database datafile '/u01/app/oracle/emp01.dbf' autoextend off;
--檢視錶空間使用情況語句
select upper(f.tablespace_name) "ts-name",
d.tot_grootte_mb "ts-bytes(m)",
d.tot_grootte_mb - f.total_bytes "ts-used (m)",
f.total_bytes "ts-free(m)",
to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
2),
'990.99') "ts-per"
from (select tablespace_name,
round(sum(bytes) / (1024 * 1024), 2) total_bytes,
round(max(bytes) / (1024 * 1024), 2) max_bytes
from sys.dba_free_space
group by tablespace_name) f,
(select dd.tablespace_name,
round(sum(dd.bytes) / (1024 * 1024), 2) tot_grootte_mb
from sys.dba_data_files dd
group by dd.tablespace_name) d
where d.tablespace_name = f.tablespace_name
order by 5 desc;
SYS@ test11g> select tablespace_name,sum(bytes)/1024/1024 free_m
2 from dba_free_space
3 group by tablespace_name;
TABLESPACE_NAME FREE_M
---------------- ----------
SYSAUX 35.125
UNDOTBS1 82
USERS .875
SYSTEM 9.8125
EXAMPLE 21.25
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27633655/viewspace-1080292/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【TABLESPACE】Oracle表空間最佳實踐Oracle
- 【TABLESPACE】Oracle 表空間結構說明Oracle
- oracle的臨時表空間temporary tablespaceOracle
- 【Oracle】oracle tablespace&datafile -- oracle表空間 分享[轉]Oracle
- Oracle基礎結構之表空間Oracle
- Oracle Bigfile Tablespace大檔案表空間Oracle
- Oracle基礎 02 臨時表空間 tempOracle
- Oracle基礎 03 回滾表空間 undoOracle
- 聊聊Oracle可傳輸表空間(Transportable Tablespace)(上)Oracle
- 聊聊Oracle可傳輸表空間(Transportable Tablespace)(中)Oracle
- 聊聊Oracle可傳輸表空間(Transportable Tablespace)(下)Oracle
- Oracle create tablespace 建立表空間語法詳解Oracle
- Oracle表空間操作詳解-入門基礎Oracle
- 表空間監控(三)tablespace detailAI
- Tablespace Fragmentation - 表空間碎片問題Fragment
- oracle基礎管理——表空間和資料檔案Oracle
- Oracle——01表空間和區Oracle
- Oracle10新特性:臨時表空間組(temporary tablespace group)Oracle
- oracle11g_基表I_DEPENDENCY1之move tablespace移動表空間到非system_Oracle
- 臨時表空間temporary tablespace相關操作
- 【tablespace】表空間離線的3種模式模式
- 使用rman在不同平臺之間傳送oracle asm表空間(transport tablespace)OracleASM
- Oracle10g新特性:臨時表空間組(temporary tablespace group)Oracle
- 利用oracle10g_rman_convert_transportable tablespace遷移表空間Oracle
- Oracle表空間Oracle
- Oracle 基礎溫習1 建立表空間和新使用者Oracle
- oracle基礎練習6章 表空間和資料檔案Oracle
- MySQL Transportable Tablespace(傳輸表空間) 使用詳解MySql
- 表空間配額和UNLIMITED TABLESPACE許可權MIT
- 基礎知識5——建立和管理表空間
- oracle temp 表空間Oracle
- 增加oracle表空間Oracle
- oracle undo 表空間Oracle
- oracle users 表空間Oracle
- Oracle表空間管理Oracle
- oracle建立表空間Oracle
- Oracle 表空間管理Oracle
- oracle表空間操作Oracle