一次生成任意多行数据的语句

Posted on 2012-12-04 10:01  JasmineLiu  阅读(218)  评论(0编辑  收藏  举报
postgres=# CREATE TABLE rtbl (
               a int,
               b int,
               t text,
               x float,
               y float
           );
CREATE TABLE

postgres=# INSERT INTO rtbl (SELECT code AS a, (code * 100 * random())::int % 57 AS b,
                             md5(code::text) || ' is check sum of code: ' || code AS d,
                             1000 * random() AS x, 1000 * random() AS y
                             FROM generate_series(1,1110000) code);
INSERT 0 1110000

postgres=# \timing

  启用计时功能.

postgres=# select count(*) from rtbl;

   count
  ---------
  1110000
  (1 行记录)

  时间:184.499 ms

 

Copyright © 2024 JasmineLiu
Powered by .NET 8.0 on Kubernetes