簡單介紹一下 表空間常用的命令

動態視圖

 oracle啓動的時候,就會建立動態性能視圖,oracle 關閉就會刪除動態性視圖

表空間

是數據庫的邏輯組成部分。是有數據文件組成的。

 

//創建表空間,第一個size是表空間的大小,第二個是 區的大小

create tablespacesp001 datafile  'd:\sp001.dbf' size 10m  uniform size 128k;

 

create table  dept2(id int,name varchar(2))tablespace  sp001;

insert into  dept2 values(1,'22');


//使表空間只讀

alter tablespacesp001 read only;

 

insert into  dept2 values(2,'22');無法插入

alter tablespacesp001 read write; 可以插入了

alter tablespacesp001 offline;防止被攻擊 (建立了表之後的狀態爲online)

 alter tablespacesp001 online;


select  table_name,tablespace_namefrom user_tables users whereusers.TABLESPACE_NAME='SP001';

 select  table_name,tablespace_namefrom user_tables users whereusers.TABLE_NAME='DEPT2';

drop tablespace   SP001 including contents  and datafiles;

select tablespace_name ,table_name from user

insert intodept2 select * from dept2;

擴展表空間

alter  tablespacesp001 add datafile 'D:\sp002.dbf' size 300m;

 alter tablespace sp001 datafile ’d:\sp001.dbf’ resize 20m;

 alter tablespace sp001 datafile ’d:\sp001.dbf’  autoextend on next 10m maxsize 500m;

  

如  [北京]-----》多快土地

 

數據庫《《表空間 《《段《《區《《塊

 

 如果你的數據文件所在的磁盤文件破壞,而數據文件沒有壞,可以通過移動到其他盤

 

1,獲得數據文件所在的表空間

Select tablespace_name from dba_data _files where  filename=’d:\sp001.dbf’;

 2,使表空間脫機

  Alter  tablespace sp001 offline;

 3,使用命令移動數據文件到指定的目錄

Host  move  d:\sp001.dbf c:sp001/mdf

 4,移動數據文件

 alter tablespace SP001 rename datafile  'D:\SP001.DBF' to 'C:\SP001.DBF'

 5, 使表空間聯機

 Alter tablespace sp001 online;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章