向数据库中插入100000条数据用什么方法比较简单,是用存储过程吗?该怎么写呢?

解决方案 »

  1.   


    Oracle 插入大量数据
      

  2.   

    循环执行insert into 表名 select * from 表名,这样不知快不快
      

  3.   

    -- 10万数据,不算大,你想怎么插入,就怎么写!但是有一点:尽量少用循环!-- 其一:如果你是将一个查询语句(执行出来的结果10万)的结果插入另一张表的话,
    -- 直接用:
    insert into table_name(col_name1, col_name2, ... col_nameN)
    select ... (这里是你的查询语句)-- 如果你是想随机创建一些测试数据的话,就用循环10万次,每次将生成一条记录各字段的随机数据插入!-- 环境不同、需求不一样,就灵活应用不同的方法!
      

  4.   

    如果是文本文件,使用sqlloader速度是最快的,不过使用有点复杂。如果只是一次性操作,使用insert/*+append*/ into table_name 即可;如果是写程序,可以用数组进行批量插入。
      

  5.   

    insert into select ...statment...
      

  6.   


    --大量数据的插入,我一般这样做:
    1、alter table tb nologging
    2、drop index index_name        --先删除表上的index,或者禁掉(若有)
    3、insert /*+append*/ into tb ..  --执行插入
    4、create index index_name on ..  --重建index
    5、alter table tb logging
      

  7.   


    SQL> create table tb(i number);--  
    Table created.  
    Elapsed: 00:00:00.09  
    SQL> insert into tb values(1);  
    1 row created.  
    Elapsed: 00:00:00.01  
    SQL> insert into tb  
      2  select * from tb;  
    1 row created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    2 rows created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    4 rows created.  
    Elapsed: 00:00:00.00  
    SQL> /  
    8 rows created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    16 rows created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    32 rows created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    64 rows created.  
    Elapsed: 00:00:00.00  
    SQL> /  
    128 rows created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    256 rows created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    512 rows created.  
    Elapsed: 00:00:00.00  
    SQL> /  
    1024 rows created.  
    Elapsed: 00:00:00.01  
    SQL> /  
    2048 rows created.  
    Elapsed: 00:00:00.03  lz 用这种方法 自增 指数增长 很快的log(100000) 次 就可以了 
    http://blog.csdn.net/mingchaoyan/archive/2011/04/16/6328009.aspx
      

  8.   

    declare
       v_count number :=1;
    begin
       while v_count < 10001  loop
       ---在这里写你的插入语句
       v_count := v_count + 1;
       end loop;
    end;
      

  9.   

    才10W数据的插入,小case,1W条comit