OMF管理文件 和 手动管理文件比较
手动管理文件 需要手动指定文件存储位置,包括名字,路径,而ORACLE-MANAGE-FILE 这一切就交给数据库系统来完成,OMF管理包括控制还包括了OS文件:如果你手动管理 当删除一个数据文件 的时候只是讲控制文件里面的信息更改了,但是真正的OS文件仍然存在
OMF管理 数据文件
使用OMF 管理 数据文件需要指定 一个参数 :db_create_file_dest(指定该参数表示开启OMF特性)
默认的是100M,采用的是autoextend 自动扩展,每次增加10M
SQL> show parameter db_create
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string
db_create_online_log_dest_1 string /thirddisk/root/redolog
db_create_online_log_dest_2 string /fourthdisk/root/redolog
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string
db_create_online_log_dest_1 string /thirddisk/root/redolog
db_create_online_log_dest_2 string /fourthdisk/root/redolog
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
我现在使用的是三面的几个参数 第一个 就是设置数据文件的自动存放位置
SQL>
alter system
set db_create_file_dest=
'/export/home/oracle/test' ;
alter system set db_create_file_dest= '/export/home/oracle/test'
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-01261: Parameter db_create_file_dest destination string cannot be
translated
ORA-01262: Stat failed on a file destination directory
Intel SVR4 UNIX Error: 2: No such file or directory
SQL> alter system set db_create_file_dest= '/export/home/oracle';
System altered.
SQL> show parameter db_create_file_dest;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string /export/home/oracle
alter system set db_create_file_dest= '/export/home/oracle/test'
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-01261: Parameter db_create_file_dest destination string cannot be
translated
ORA-01262: Stat failed on a file destination directory
Intel SVR4 UNIX Error: 2: No such file or directory
SQL> alter system set db_create_file_dest= '/export/home/oracle';
System altered.
SQL> show parameter db_create_file_dest;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string /export/home/oracle
上面可以看到 设置目录 要保存目录存在,继续 我们还是先
1>手动添加一个数据文件
SQL> l
1* create tablespace t1 logging datafile '/export/home/oracle/t1.dbf' size 50M
SQL> /
Tablespace created.
SQL> !ls
afiedt.buf local.cshrc local.login local.profile t1.dbf
SQL> drop tablespace t1 including contents;
Tablespace dropped.
SQL> ls
SP2-0042: unknown command "ls" - rest of line ignored.
SQL> !ls
afiedt.buf local.cshrc local.login local.profile t1.dbf
1* create tablespace t1 logging datafile '/export/home/oracle/t1.dbf' size 50M
SQL> /
Tablespace created.
SQL> !ls
afiedt.buf local.cshrc local.login local.profile t1.dbf
SQL> drop tablespace t1 including contents;
Tablespace dropped.
SQL> ls
SP2-0042: unknown command "ls" - rest of line ignored.
SQL> !ls
afiedt.buf local.cshrc local.login local.profile t1.dbf
看看 当删除表空间的饿时候 t1.dbf仍然存在 没有节省空间,不过 ORACLE 10G也提供了 一个兼容的方式
SQL> !rm -r t1.dbf
SQL> !ls
afiedt.buf local.cshrc local.login local.profile
SQL> create tablespace t1 logging datafile '/export/home/oracle/t1.dbf' size 50M;
Tablespace created.
SQL> !ls
afiedt.buf local.cshrc local.login local.profile t1.dbf
SQL> drop tablespace t1 including contents and datafiles;
Tablespace dropped.
SQL> !ls
afiedt.buf local.cshrc local.login local.profile
这样 就删除了
2>OMF创建数据文件
SQL> create tablespace t1;
Tablespace created.
SQL> !ls ORCL/datafile
o1_mf_t1_54yn91dp_.dbf
Tablespace created.
SQL> !ls ORCL/datafile
o1_mf_t1_54yn91dp_.dbf
看到效果了吧! 我没有指定文件的存储位置 自动给我存储在了 上面设置的/export/home/oracle目录下 它自己创建了一个 SID/datafile目录(如果是存储重做日志文件则会创建SID/onlinefile目录)
下面看看删除效果
SQL>
drop tablespace t1;
Tablespace dropped.
SQL> !ls ORCL/datafile
Tablespace dropped.
SQL> !ls ORCL/datafile
奇怪吧 没有文件了 Oracle RDMS 给我们自动讲OS文件删除了 OK
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24984814/viewspace-707779/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24984814/viewspace-707779/