0

I m creating a unix script for our prod enviornment. Requirement is to create a backup of table (not the entire table) few rows. Perform some operation on table(update and delete). At end delete new data and restore back. Problem is how to take backup in prod enviornment. I cant have temp table there.

Script it something like this.

spool below query
select 'insert into <tablename> values ( ' || col_1 || ','|| col_2 || ','|| col_3 .. so on
from <tablename> <where condition>  --- generate backup

perform operation on table <delete/update>

delete new values 

Restore backup executing spool file

I find this appoarch kind of tedious, is there any better way to accomplish this task?

Note :- This script will be executed in prod where I dont have access to create table. Can perform only update/delete on given table.

Database - 10g

4

1 回答 1

0

不幸的是,不那么乏味的方法是使用临时表方法,当然最好是在不同的模式中。将所有操作和数据保存在数据库中会更快、更简单、更可靠。

或者,如果这不是一个冗长的时间尺度并且数据上没有发生其他更改,您可以使用FLASHBACK TABLE 。如果确实发生了其他更改,那么使用闪回查询子句恢复旧数据只会稍微复杂一些。

于 2013-06-05T10:01:56.893 回答