目录
1、表备份
2、表还原
1、表备份
表备份和表还原恢复,都必须在联机状态下进行。
与备份数据库与表空间不同,不需要备份归档日志,不存在增量备份之说。
CREATE TABLE TAB_FOR_RES_02(C1 INT);CREATE INDEX I_TAB_FOR_RES_02 ON TAB_FOR_RES_02(C1);insert into TAB_FOR_RES_02 values (1);commit;BACKUP TABLE TAB_FOR_RES_02 BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';
2、表还原
1.指定表名还原时数据库中必须存在该表,否则报错,不会从备份集判断是否存在目标表。
2.若在语句中指定 STRUCT 关键字,则执行表结构还原。表结构还原会根据备份集中备份表还原要求,对目标表定义进行校验,并删除目标表中已存在的二级索引和约束。
3.若不指定 STRUCT 关键字,则执行表数据还原,表数据还原默认仅会将备份表中聚集索引上的数据进行还原。
创建表
CREATE TABLE TAB_FOR_RES_02(C1 INT);
还原索引约束
RESTORE TABLE TAB_FOR_RES_02 STRUCT FROM BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';
还原数据
RESTORE TABLE TAB_FOR_RES_02 FROM BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';
SQL> CREATE TABLE TAB_FOR_RES_02(C1 INT);操作已执行已用时间: 6.245(毫秒). 执行号:918.SQL> CREATE INDEX I_TAB_FOR_RES_02 ON TAB_FOR_RES_02(C1);操作已执行已用时间: 12.137(毫秒). 执行号:919.SQL> insert into TAB_FOR_RES_02 values (1);commit;DMSQL 过程已成功完成已用时间: 2.600(毫秒). 执行号:920.SQL> select owner,index_name,table_owner,table_name from SYS.DBA_INDEXES a where a.INDEX_NAME='I_TAB_FOR_RES_02';行号 OWNER INDEX_NAME TABLE_OWNER TABLE_NAME ---------- ------ ---------------- ----------- --------------1 SYSDBA I_TAB_FOR_RES_02 SYSDBA TAB_FOR_RES_02已用时间: 2.320(毫秒). 执行号:923.SQL> BACKUP TABLE TAB_FOR_RES_02 BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';操作已执行已用时间: 00:00:02.859. 执行号:925.SQL> drop table TAB_FOR_RES_02;操作已执行已用时间: 19.199(毫秒). 执行号:926.SQL> RESTORE TABLE TAB_FOR_RES_02 STRUCT FROM BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';RESTORE TABLE TAB_FOR_RES_02 STRUCT FROM BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';第1 行附近出现错误[-2106]:无效的表或视图名[TAB_FOR_RES_02].已用时间: 0.602(毫秒). 执行号:0.SQL> CREATE TABLE TAB_FOR_RES_02(C1 INT);操作已执行已用时间: 5.637(毫秒). 执行号:927.SQL> RESTORE TABLE TAB_FOR_RES_02 STRUCT FROM BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';操作已执行已用时间: 10.764(毫秒). 执行号:928.SQL> select owner,index_name,table_owner,table_name from SYS.DBA_INDEXES a where a.INDEX_NAME='I_TAB_FOR_RES_02';未选定行已用时间: 0.470(毫秒). 执行号:929.SQL> select owner,index_name,table_owner,table_name from SYS.DBA_INDEXES a where table_name='TAB_FOR_RES_02';行号 OWNER INDEX_NAME TABLE_OWNER TABLE_NAME ---------- ------ ------------- ----------- --------------1 SYSDBA INDEX33555724 SYSDBA TAB_FOR_RES_02已用时间: 19.652(毫秒). 执行号:930.SQL> select * from TAB_FOR_RES_02;未选定行已用时间: 0.923(毫秒). 执行号:931.SQL> RESTORE TABLE TAB_FOR_RES_02 FROM BACKUPSET '/dm/backup/dm_bak/tab_bak_for_res_02';操作已执行已用时间: 37.959(毫秒). 执行号:932.SQL> select * from TAB_FOR_RES_02;行号 C1 ---------- -----------1 1已用时间: 1.074(毫秒). 执行号:933.SQL>
达梦技术社区:https://eco.dameng.com/