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