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;
    
  • 相关阅读:
    mybatis+sql语句
    坐标转换
    sql语句含中文JDBC查询不到
    架构阅读笔记16
    架构阅读笔记15
    架构阅读笔记14
    windows安装imgaug包报错中Shapely
    java除法
    Java输入输出问题复习
    java自学,基础,入门
  • 原文地址:https://www.cnblogs.com/yldf/p/11900026.html
Copyright © 2011-2022 走看看