Re: How to insert random character data into tables for testing purpose. THanks. - Mailing list pgsql-general

From Andreas Kretschmer
Subject Re: How to insert random character data into tables for testing purpose. THanks.
Date
Msg-id 20120502163214.GA14413@tux
Whole thread Raw
In response to How to insert random character data into tables for testing purpose. THanks.  (leaf_yxj <leaf_yxj@163.com>)
Responses Re: How to insert random character data into tables for testing purpose. THanks.
List pgsql-general
leaf_yxj <leaf_yxj@163.com> wrote:

> Hi Guys, I want to insert the random character data into tables for testing
> purpose.
> I created a table as follows :
>
> create table test ( id int, b char(100));
>
> I need to insert 100000 rows into this table. I know how to insert
> generate_series  into coloumn ID. But I don't how to insert the Random
> string data into column b.

something like:

test=# create table t_random as select s, md5(random()::text) from generate_Series(1,5) s;
SELECT 5
Time: 163,624 ms
test=*# select * from t_random ;
 s |               md5
---+----------------------------------
 1 | ef82dcb3e8465fa9a7494c569dfa093f
 2 | ad6ae62bb4a49c7889aba0bfcba224ff
 3 | 27717d30d8cf069b3129853d90ae5035
 4 | 530c200678711a414e000c60e73286bd
 5 | 2b2c3692da1b60760ff95d41cdf9b82d
(5 rows)



Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Removal of BSDi, BSD/OS port
Next
From: Radosław Smogura
Date:
Subject: Re: Which Java persistence library would you use with PostgreSQL?