表空间还原,常见的场景是用户表空间的数据文件丢失或者损坏,此时需要通过数据库备份文件,将用户表空间还原到最新状态。
若某一张表被删除了,由于删除了表,数据库对象肯定发生了变化,想要恢复这张表,只能通过全库还原的方式。
下述为详细步骤:
disql /nolog
SQL>conn SYSDBA/SYSDBA@localhost:5236
SQL>sp_set_para_value(1,'FIL_CHECK_INTERVAL',1);
SQL>CREATE TABLESPACE TEST DATAFILE 'TEST.DBF' size 150;
SQL>CREATE USER TEST IDENTIFIED BY "123456789" default tablespace "TEST";
SQL>GRANT CREATE TABLE TO TEST;
SQL>conn TEST/123456789@localhost:5236
SQL>CREATE TABLE T1(C1 VARCHAR(20),C2 VARCHAR(20));
SQL>INSERT INTO T1 SELECT LEVEL,LEVEL+1 FROM DUAL CONNECT BY LEVEL<=10000;
SQL>COMMIT;
SQL>BACKUP DATABASE BACKUPSET 'db_full_bak_for_ts';
SQL>SELECT SF_BAKSET_CHECK('DISK','/dbbak/CNDT/db_full_bak_for_ts ');
SQL>INSERT INTO T1 SELECT LEVEL,LEVEL+1 FROM DUAL CONNECT BY LEVEL<=10000;
SQL>COMMIT;
SQL>SELECT COUNT(*) FROM TEST.T1;
rm –rf /dbdata/CNDT/TEST.DBF
disql /nolog
SQL>CONN TEST/123456789@localhost:5236
SQL>SELECT COUNT(*) FROM TEST.T1;
SELECT COUNT(*) FROM TEST.T1;
disql /nolog
SQL>CONN TEST/123456789@localhost:5236
SQL>ALTER TABLESPACE TEST OFFLINE;
SQL>RESTORE TABLESPACE TEST FROM BACKUPSET '/dbbak/CNDT/db_full_bak_for_ts';
SQL>ALTER TABLESPACE TEST ONLINE;
SQL>SELECT COUNT(*) FROM TEST.T1;
–查询出来为 20000,即表空间恢复成功。
文章
阅读量
获赞