database - Teradata SQL : insert random data for testing into Table -
i trying create random data , insert table. right thinking what'd efficient approaches done. e.g.
create volatile table mytb , no fallback, no journal ( c1 integer not null c2 varchar (50) not null , c3 d1 date not null, c4 d2 date not null ) data primary index ( c1) on commit preserve rows;
what want insert value randomly x iterations specific list or range of each column value . e.g. c1 range between 30 , 3000000 c2 list ( 'approved','pending','unknown','disputed','wip','processed','pre-processed','denied' ) etc c3 date between 01-01-1999 12-31-2015 etc 1 million iterations i'd insert random values these columns , create skew values- there should abundance of these values vs rest. has had dig @ before . best way - recursive q logic ?
i use random
produce test data:
select random(30,3000000) c1, case random(1,8) when 1 'approved' when 2 'pending' when 3 'unknown' when 4 'disputed' when 5 'wip' when 6 'processed' when 7 'pre-processed' when 8 'denied' end, date '1999-01-01' + random(0,6208) -- 2015-12-31 sys_calendar.calendar -- table large number of rows
this results in evenly distributed data, if want skew can run different insert/selects or play around multiple randoms:
random(1,50) + random(0,50) (random(1, 50) * random(1,200) + random(0,100)) / 100.00
Comments
Post a Comment