zoukankan      html  css  js  c++  java
  • Postgres快速创建大量测试数据

    DROP TABLE  IF EXISTS color;
    CREATE TABLE color(
        cname VARCHAR(20),
        remark VARCHAR(20)
    );
    insert into color select round(random()*100),round(random()*1000) from generate_series(1,10000000);

    插入10000000数据之后,用时51秒

    对于generate_series函数,还可以生成时间:

    david=# select generate_series(now(), now() + '7 days', '1 day');
            generate_series        
    -------------------------------
     2013-04-03 14:22:26.391852+08
     2013-04-04 14:22:26.391852+08
     2013-04-05 14:22:26.391852+08
     2013-04-06 14:22:26.391852+08
     2013-04-07 14:22:26.391852+08
     2013-04-08 14:22:26.391852+08
     2013-04-09 14:22:26.391852+08
     2013-04-10 14:22:26.391852+08
    (8 rows)
    
    david=# select generate_series(to_date('20130403','yyyymmdd'), to_date('20130404','yyyymmdd'), '3 hours');  
        generate_series     
    ------------------------
     2013-04-03 00:00:00+08
     2013-04-03 03:00:00+08
     2013-04-03 06:00:00+08
     2013-04-03 09:00:00+08
     2013-04-03 12:00:00+08
     2013-04-03 15:00:00+08
     2013-04-03 18:00:00+08
     2013-04-03 21:00:00+08
     2013-04-04 00:00:00+08
    (9 rows)
  • 相关阅读:
    Interrupt、Interrupted、IsInterrupted
    ReentrantLock
    tcp粘包、拆包
    jstat 分析应用垃圾回收状况
    CopyOnWriteArrayList
    storm基础概念
    余弦距离
    websocket
    awk
    sed
  • 原文地址:https://www.cnblogs.com/winkey4986/p/6370820.html
Copyright © 2011-2022 走看看