{"id":103,"date":"2008-12-17T16:18:52","date_gmt":"2008-12-17T21:18:52","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2008\/12\/17\/creating-an-oracle-table-pre-filled-with-random-values\/"},"modified":"2008-12-17T16:18:52","modified_gmt":"2008-12-17T21:18:52","slug":"creating-an-oracle-table-pre-filled-with-random-values","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2008\/12\/17\/creating-an-oracle-table-pre-filled-with-random-values\/","title":{"rendered":"Creating an Oracle table pre-filled with random values"},"content":{"rendered":"<p>The code makes use of Oracle&#8217;s dbms_random package and some very light-weight PL\/SQL.  You may adjust the number of fields, field data types, total number of records, etc. to suit your needs.<\/p>\n<pre class=\"code\">\ncreate table schema.test_data (\n  txt  varchar2(10), \n  numb  number(10), \n  dt  date\n);\nbegin\n  for i in 1..10000 loop\n    insert into schema.test_data values (dbms_random.string('X',10), dbms_random.value(0,20), to_date(trunc(dbms_random.value(2422599, 2457085)),'j'));\n  end loop;\n  commit;\nend;\n<\/pre>\n<p>When we are done, we will see that the table contains 10,000 records as we specified in the sample code above.<\/p>\n<pre class=\"code\">\nselect count(*) from schema.test_data;\n\n  COUNT(*)\n----------\n     10000\n<\/pre>\n<p>Below is what the data may look like.<\/p>\n<pre class=\"code\">\nselect txt, numb, to_char(dt,'mm\/dd\/yyyy') as dt from schema.test_data where rownum<10;\n\nTXT              NUMB DT\n---------- ---------- ----------\n35W6DQ986O          7 11\/26\/1943\n8NOOSRH6R2          8 01\/18\/1993\n7HPKA10GKQ         16 10\/07\/2012\nI90Z9YVWHW          2 11\/01\/1939\nWNNW1M7BNM         15 10\/27\/1982\nR9OQF67QWP         13 08\/28\/1926\nPD39YGY35D         10 02\/04\/1952\nN8R8DKMAIO         15 07\/06\/1986\n43MELQ9M0Q          3 06\/19\/1921\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To test out a newly written database application, we often need a large quantity of test data in order to see if the program handles various things.  This sample demonstrates how we can quickly generate an Oracle database table pre-filled with as much test data as we need.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}