zoukankan      html  css  js  c++  java
  • oracle快速构造数据

    新建存储过程

    create or replace procedure generate_data(tbl_name varchar,min_value int, max_value int) is
        MAX_NUM integer := max_value;
        MIN_NUM integer := min_value;
        tmp_val varchar2(100):='';
    BEGIN
        for i in MIN_NUM..MAX_NUM
        loop
            tmp_val:='u'||i;
            execute immediate 'insert into '||tbl_name ||' values(:1, :2)' using i,tmp_val;  --insert语句末尾不能有分号,否则出错
        end loop;
        commit;
    END;
    
    • 建表
    create table test0(id int, name varchar2(100));
    
    • 调用存储过程,生成数据
    begin
        generate_data('test0',1,10000000);
    end; 
    
    • 新建其他表
    create table test1 as select * from test0;
    create table test2 as select * from test0;
    create table test3 as select * from test0;
    create table test4 as select * from test0;
    create table test5 as select * from test0;
    create table test6 as select * from test0;
    create table test7 as select * from test0;
    create table test8 as select * from test0;
    create table test9 as select * from test0;
    
  • 相关阅读:
    ruby学习总结03
    ruby学习总结02
    ruby学习总结01
    mongodb学习笔记
    mongodb数据库设计原则
    activiti学习总结
    Scala学习——隐式转换
    Scala学习——函数高级操作
    Scala学习——模式匹配
    Scala学习——集合
  • 原文地址:https://www.cnblogs.com/yldf/p/11900026.html
Copyright © 2011-2022 走看看