How to delete data files accidentally

Source: Internet
Author: User

Delete a data file accidentally. delete a data file in non-archive mode. In order to minimize the risk, force open the database. We first delete a data file, and now open the database [html] SQL> shutdown abort; ORACLE instance shut down. SQL> startup; ORA-32004: obsolete and/or deprecated parameter (s) specified ORACLE instance started. total System Global Area 167772160 bytes Fixed Size 1218316 bytes Variable Size 79694068 bytes Database Buffers 83886080 bytes Redo Buffers 2973696 bytes Database mounted. ORA-01157: cannot identify/lock data file 7-see DBW R trace file ORA-01110: data file 7: '/u01/app/oracle/oradata/orcl/tsp_test01.dbf' SQL> alter database open; alter database open * ERROR at line 1: ORA-01157: cannot identify/lock data file 7-see DBWR trace file ORA-01110: data file 7: '/u01/app/oracle/oradata/orcl/tsp_test01.dbf' we can see that, when the database stops in the mount stage and starts to open, an error is reported, indicating that the data file with file_id = 7 cannot be identified or locked. This file was just deleted. What should I do if I have to open the database now? We can set this data file OFFLINE as follows: [html] SQL> alter database datafile '/u01/app/oracle/oradata/orcl/tsp_test01.dbf' offline; database altered. open the database now: [html] SQL> alter Database open; database altered. the database is opened. Now that we open the database, we have to check the impact of the loss of this data file on the objects in the database, in this way, we can clearly understand the damage caused by errors to the database. Therefore, we need to find the objects affected by these receipts, first, we know that the tablespace [html] SQL> select tablespace_name from dba_data_files where file_id = '7'; TABLESPACE_NAME -------------------------- TSP_TEST obtains the name of the tablespace: TSP_TEST, the following figure shows the objects in the tablespace: [html] SQL> select OWNER, TABLESPACE_NAME, EXTENTS, HEADER_FILE, SEGMENT_NAME from dba_segments where tablespace_name = 'tsp _ TES T '; OWNER TABLESPACE_NAME EXTENTS HEADER_FILE SEGMENT_NAME should begin --------------- begin TEST TSP_TEST 21 7 BIN $ tables/AQB4Dg = $0 TEST TSP_TEST 21 7 TEST7 so that we can clearly lay the foundation for the next rescue. 2. accidentally deleted the data file. In the archive mode, how can we restore the database to create the tablespace tp_test, table test10, index ind_test10 [html] SQL> create tablespace tp_test datafile '/u01/app/oracle/oradata/orcl/tp_test01.dbf' size 10 M; Tablespace created. SQL> create table test10 (v_num number) tablespace tp_test; Table created. SQL> create index ind_test10 on test10 (v_num) tablespace tp_test; Index created. manually delete data files, simulate power-off, and then start [html] SQL> shutdown abort ORACLE in Stance shut down. SQL & gt; startup ORA-32004: obsolete and/or deprecated parameter (s) specified ORACLE instance started. total System Global Area 167772160 bytes Fixed Size 1218316 bytes Variable Size 67111156 bytes Database Buffers 96468992 bytes Redo Buffers 2973696 bytes Database mounted. ORA-01157: cannot identify/lock data file 8-see DBWR trace file ORA-01110: data file 8: '/u01/app/oracle/orad Ata/orcl/tp_test01.dbf found that it was started into the mount stage and cannot be opened. Next, we need to restore the database, create a data file, and enable the automatic recovery function, restore the data file [html] SQL> alter database create datafile '/u01/app/oracle/oradata/orcl/tp_test01.dbf'; Database altered. SQL> set autorecovery on; SQL> recover datafile '/u01/app/oracle/oradata/orcl/tp_test01.dbf'; Media recovery complete. SQL> alter database open; Database altered. SQL> select * from test10; no rows selected. The table is still complete.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.