How to generate sample test data

Step 1:
Let us just say if where have a table with the below structure
SQL> desc address
 Name                                      Null?    Type
 ----------------------------------------- -------- ------------
 STREET                                             VARCHAR2(32)
 CITY                                                  VARCHAR2(20)
 STATE                                                CHAR(2)
 POSTAL_CODE                                VARCHAR2(6)

Step2:
Use the dbms_random package to generate sample data to populate this table.
I agree this is not generating any meaningful data, but it just can be used to populate data for testing purpose.
SQL> INSERT INTO address
  2         SELECT DBMS_RANDOM.STRING ('a', 32) street,
  3                DBMS_RANDOM.STRING ('a', 20) city,
  4                DBMS_RANDOM.STRING ('u', 2) state,
  5                ROUND (DBMS_RANDOM.VALUE (90000, 99999)) zip
  6           FROM DUAL
  7     CONNECT BY LEVEL <= 1000;

1000 rows created.

Step3:
Below is a sample data



No comments:

Post a Comment