The following code generates 100000 rows with random values for uuid_generate_v4() but the inner selects are always choosing the same row so all the resulting rows have the same values. The idea is that each select will choose one value from a random row to generate 100000 rows. How can this be fixed?
insert into "Tag" (
"Id", "Time", "Account", "Name", "Value", "RollUpTableId"
)
select
uuid_generate_v4(),
current_timestamp,
(select "Account" from "AccountSamples" OFFSET floor(random()*358) LIMIT 1),
(select "Name" from "TagNameSamples" OFFSET floor(random()*19) LIMIT 1),
(select "Value" from "TagValueSamples" OFFSET floor(random()*26) LIMIT 1),
uuid_generate_v4()
from generate_series(1, 100000);
Aucun commentaire:
Enregistrer un commentaire