How to Generate Random Data in Oracle

DROP TABLE t;
CREATE TABLE t (
  x VARCHAR(20),
  y NUMERIC(20,2),
  z INT
);

BEGIN
  FOR i IN 1..20000 LOOP
    INSERT INTO t VALUES (
      dbms_random.string('L', 20),
      dbms_random.Value,
      dbms_random.value(1,1000)
    );
  END LOOP;
  COMMIT;
END;
/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s