天天看點

Oracle 資料檔案管理

1、手工改變資料檔案的大小

SQL>conn / as sysdba

SQL>Createtablespace exampletb Datafile 'E:\ examp01.dbf' size 10M ;

SQL>alter database datafile 'E:\examp01.dbf' resize 20m;

SQL>alter database datafile 'E:\examp01.dbf' resize 9m;

2、加入資料檔案到表空間

SQL> alter tablespace exampletb add datafile 'E:\ examp02.dbf' size 10M;

3、從表空間中删除資料檔案

SQL> alter tablespace exampletb drop datafile 'E:\ examp02.dbf';

4、将表空間設定為僅僅讀模式和讀寫模式

SQL>CREATETABLE scott.student (id NUMBER(5), name VARCHAR2(10)) TABLESPACE exampletb;

SQL>insertinto scott.student(id,name) values(1, 'lucy');

SQL> alter tablespace exampletb read only;

SQL>insertinto scott.student(id,name) values(2, 'lily');

SQL>select* from scott.student;

      SQL> alter tablespace exampletb read write。

5、 将表空間設定為線上和離線

SQL> alter tablespace exampletb offline;

SQL> alter tablespace exampletb online;

6、查詢表空間和資料檔案

SQL>select * from v$tablespace;

SQL>select * from dba_tablespaces;

SQL>select * from v$datafile;

SQL> select * from dba_data_files;