Re: How to generate random string for all rows in postgres

2021-01-04 Thread Rad Akefirad
Got it. Many thanks. On Mon, Jan 4, 2021 at 2:46 PM hubert depesz lubaczewski wrote: > On Mon, Jan 04, 2021 at 02:14:11PM +0100, Hassan Akefirad wrote: > > I have foo table and would like to set bar column to a random string. > I've got the following query: > > update foo > > set bar = array_to_

Re: How to generate random string for all rows in postgres

2021-01-04 Thread hubert depesz lubaczewski
On Mon, Jan 04, 2021 at 02:14:11PM +0100, Hassan Akefirad wrote: > I have foo table and would like to set bar column to a random string. I've > got the following query: > update foo > set bar = array_to_string( > array(select string_agg(substring('0123456789bcdfghjkmnpqrstvwxyz', > round(random()

How to generate random string for all rows in postgres

2021-01-04 Thread Hassan Akefirad
I have foo table and would like to set bar column to a random string. I've got the following query: update foo set bar = array_to_string( array(select string_agg(substring('0123456789bcdfghjkmnpqrstvwxyz', round(random() * 30)::integer, 1), '') from generate_series(1, 9)), ''); But it generates t