Oracle表空間相關操作
檢視錶空間名字
select name from v$tablespace;
建立表空間-初始大小為10M 自動增長50M;
create tablespace ts datafile '/opt/oracle/oradata/orcl/ts.dbf' size 10m autoextend on next 1m;
刪除表空間
drop tablespace ts including contents and datafiles cascade constraints;
drop user user1 cascade
擴充套件表空間的3種方法:
1.手動增加資料檔案大小
alter database datafile '/home/oracle/ts01.dbf' resize 100m;
2.把表空間設定為自動擴充套件
alter database datafile '/home/oracle/ts01.dbf' autoextend on next 5m maxsize unlimited;
3. 往表空間增加資料檔案
alter tablespace ts01 add datafile '/home/oracle/ts02.dbf' size 2m;
更改表空間名字
alter tablespace ts01 rename to ts02;
表空間使用率
select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
from
(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc;
表空間的存放位置
select file_name, tablespace_name from dba_data_files;
遷移表空間的物理位置
1、select file_name, tablespace_name from dba_data_files;
FILE_NAME TABLESPACE_NAME
------------------------------- ---------------------
/home/oracle/ts01.dbf TS02
/home/oracle/ts02.dbf TS02
2、alter tablespace ts02 offline normal;
3、使用作業系統命令使表空間 ts02 由/home/oracle 移動到/opt/oracle/oradata/orcl
cp -rf ts01.dbf ts02.dbf /opt/oracle/
4、修改資料檔案ts02的控制資訊檔案
alter tablespace ts rename datafile '/home/oracle/ts.dbf' to '/opt/oracle/oradata/orcl/ts.dbf';
5、使表空間線上
SQL> alter tablespace ts02 online;
遷移成功,查詢資料檔案當前位置
select name from v$datafile;
[@more@]
select name from v$tablespace;
建立表空間-初始大小為10M 自動增長50M;
create tablespace ts datafile '/opt/oracle/oradata/orcl/ts.dbf' size 10m autoextend on next 1m;
刪除表空間
drop tablespace ts including contents and datafiles cascade constraints;
drop user user1 cascade
擴充套件表空間的3種方法:
1.手動增加資料檔案大小
alter database datafile '/home/oracle/ts01.dbf' resize 100m;
2.把表空間設定為自動擴充套件
alter database datafile '/home/oracle/ts01.dbf' autoextend on next 5m maxsize unlimited;
3. 往表空間增加資料檔案
alter tablespace ts01 add datafile '/home/oracle/ts02.dbf' size 2m;
更改表空間名字
alter tablespace ts01 rename to ts02;
表空間使用率
select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
from
(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc;
表空間的存放位置
select file_name, tablespace_name from dba_data_files;
遷移表空間的物理位置
1、select file_name, tablespace_name from dba_data_files;
FILE_NAME TABLESPACE_NAME
------------------------------- ---------------------
/home/oracle/ts01.dbf TS02
/home/oracle/ts02.dbf TS02
2、alter tablespace ts02 offline normal;
3、使用作業系統命令使表空間 ts02 由/home/oracle 移動到/opt/oracle/oradata/orcl
cp -rf ts01.dbf ts02.dbf /opt/oracle/
4、修改資料檔案ts02的控制資訊檔案
alter tablespace ts rename datafile '/home/oracle/ts.dbf' to '/opt/oracle/oradata/orcl/ts.dbf';
5、使表空間線上
SQL> alter tablespace ts02 online;
遷移成功,查詢資料檔案當前位置
select name from v$datafile;
[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23682146/viewspace-1058331/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle - 表空間相關常用操作語句Oracle
- 【原創】表空間相關操作
- oracle臨時表空間相關Oracle
- 臨時表空間temporary tablespace相關操作
- Oracle 表空間查詢相關sqlOracleSQL
- oracle表空間操作Oracle
- 表空間相關查詢
- Oracle - 表空間使用情況及相關字典Oracle
- Oracle 表空間 的操作Oracle
- 傳輸表空間操作-OracleOracle
- oracle表空間日常操作管理Oracle
- Oracle表空間操作詳解Oracle
- Oracle SQL 基本操作之 表空間OracleSQL
- oracle 10g表空間操作Oracle 10g
- oracle10g缺少tempfile(臨時表空間)_offline相關表空間測試筆記Oracle筆記
- 表空間基本操作
- 表空間、段、區、塊的相關總結
- Oracle 18c新特性詳解 - 表和表空間相關的新特性Oracle
- 將ORACLE資料庫審計相關的表移動到其他表空間Oracle資料庫
- Oracle切換undo表空間操作步驟Oracle
- Oracle表空間Oracle
- Oracle表空間操作詳解-入門基礎Oracle
- oracle 臨時表空間基本常識和操作Oracle
- 關於oracle表空間的規劃方法Oracle
- oracle temp 表空間Oracle
- 增加oracle表空間Oracle
- oracle undo 表空間Oracle
- oracle users 表空間Oracle
- Oracle表空間管理Oracle
- oracle建立表空間Oracle
- Oracle 表空間管理Oracle
- ORACLE MOVE表空間Oracle
- ORACLE表空間概述Oracle
- Oracle表空間命令Oracle
- Oracle 表空間回收Oracle
- 時間相關的操作
- 關於undo表空間的一些常用操作
- 【AWR】該怎樣清理SYSAUX表空間相關資料UX