orcale数据库备份表和删除表

1、tablenamearray为表名称的数组;

2、suffix为新生成表的后缀;

declare 
type tablenamearray is VARRAY(1000) of varchar2(1000); 
tabel_names tablenamearray := tablenamearray('department','cim_table_relation','cim_field_dictionary'); 
total integer; num integer; 
suffix varchar2(20):='_x'; 
begin total := tabel_names.count;
 FOR i in 1 .. total 
    LOOP 
        select count(1) into num from user_tables where table_name = upper(tabel_names(i) || suffix); 
        if num > 0 then
           execute immediate 'drop table ' || tabel_names(i) || suffix; end if; 
           execute immediate 'create table ' || tabel_names(i) || suffix || ' as select * from ' || tabel_names(i); 
           --dbms_output.put_line(i || ':' || tabel_names(i)); 
    END LOOP;
end; 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值