SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /oradata/arch/oralocal
Oldest online log sequence 101
Current log sequence 103
SQL>
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIV STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ------ -------------------------------- ------------- ------------
1 1 103 10485760 1 NO CURRENT 832673 08-DEC-07
2 1 101 10485760 1 NO INACTIVE 832669 08-DEC-07
3 1 102 10485760 1 NO INACTIVE 832671 08-DEC-07
SQL> create tablespace test datafile '/oradata/test.dbf' size 1m;
Tablespace created.
SQL> create table hr.xx tablespace test as select * from dba_users where 1=2;
Table created.
SQL> insert into hr.xx select * from dba_users;
37 rows created.
SQL> /
37 rows created.
SQL> /
37 rows created.
SQL> /
37 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from hr.xx;
COUNT(*)
----------
148
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIV STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ------ -------------------------------- ------------- ------------
1 1 103 10485760 1 NO CURRENT 832673 08-DEC-07
2 1 101 10485760 1 NO INACTIVE 832669 08-DEC-07
3 1 102 10485760 1 NO INACTIVE 832671 08-DEC-07
SQL> !
[oracle@localdb ~]$ cd /oradata
[oracle@localdb oradata]$ ll
total 1088
drwxr-xr-x 3 oracle dba 4096 Dec 6 15:42 arch
drwxr-xr-x 3 oracle dba 4096 Dec 6 15:37 cfile
drwxr-xr-x 3 oracle dba 4096 Dec 6 16:19 dfile
drwxr-xr-x 3 oracle dba 4096 Dec 6 15:37 lfile
drwx------ 2 oracle dba 16384 Dec 6 15:33 lost+found
-rw-r----- 1 oracle dba 1056768 Dec 8 11:23 test.dbf
[oracle@localdb oradata]$ rm test.dbf
[oracle@localdb oradata]$ ll
total 48
drwxr-xr-x 3 oracle dba 4096 Dec 6 15:42 arch
drwxr-xr-x 3 oracle dba 4096 Dec 6 15:37 cfile
drwxr-xr-x 3 oracle dba 4096 Dec 6 16:19 dfile
drwxr-xr-x 3 oracle dba 4096 Dec 6 15:37 lfile
drwx------ 2 oracle dba 16384 Dec 6 15:33 lost+found
[oracle@localdb oradata]$ exit
exit
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIV STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ------ -------------------------------- ------------- ------------
1 1 103 10485760 1 NO CURRENT 832673 08-DEC-07
2 1 101 10485760 1 NO INACTIVE 832669 08-DEC-07
3 1 102 10485760 1 NO INACTIVE 832671 08-DEC-07
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
SQL> startup
ORACLE instance started.
Total System Global Area 313860096 bytes
Fixed Size 1299624 bytes
Variable Size 276826968 bytes
Database Buffers 29360128 bytes
Redo Buffers 6373376 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/oradata/test.dbf'
SQL> alter database datafile 6 offline;
alter database datafile 6 offline
*
ERROR at line 1:
ORA-01145: offline immediate disallowed unless media recovery enabled
SQL> alter database datafile 6 offline drop;
Database altered.
SQL> alter database create datafile 6 as '/oradata/test.dbf';
Database altered.
SQL> recover datafile 6;
Media recovery complete.
SQL> alter database open;
Database altered.
SQL> select count(*) from hr.xx;
select count(*) from hr.xx
*
ERROR at line 1:
ORA-00376: file 6 cannot be read at this time
ORA-01110: data file 6: '/oradata/test.dbf'
SQL> alter database datafile 6 online;
Database altered.
SQL> select count(*) from hr.xx;
COUNT(*)
----------
148
4条评论
10.2才可以drop empty datafile。。
10.1还没有这个功能。这个是需要注意 的
re 古董:谢谢提醒,之前确实不知道10.1是没这个功能的。
最重要的,还是要拿掉文件系统的写权限,这样就不至于加数据文件加到文件系统了。人为错误不可避免,还是靠技术来尽量保障比较可靠些
re NinGoo:是加到了oracle的软件的安装目录下,控制不了-_-!
我们的HPUX的机器上,对vg确实只给root权限,里面的lv给oracle权限,所以在vg下就不能加不存在的文件系统了。