oracle批量导出每张表的100条数据


declare
   old_owner      varchar2(100)  :='';  --定义原schema
   old_table      varchar2(100)  :='';  --定义原表名
    v_sql         varchar2(2000) :='';  --定义拼接语句
    --定义游标
    cursor c_tab is select owner,table_name from 
                all_all_tables t where t.owner in ('AA','BB','CC');
begin
   for v_tab in c_tab LOOP  --for循环自带隐式关闭游标
        old_owner :=v_tab.owner;
        old_table :=v_tab.table_name;
        v_sql :='create table twe.'||old_table||' as select * from '||old_owner||'.'||old_table
                  ||' where rownum < 100';
        
        begin
              execute immediate v_sql;
         exception when others then --当出现重复表名时跳过
             null;
        end;
    end loop;
end;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM