1. SPEForums need your contributions to build up a strong repository of performance engineering resources.

    Dismiss Notice
  2. Whatsapp Group For Software Performance Engineering Professionals!! Click here to get added . No Spam for strictly professional discussions only.
    Dismiss Notice
Dismiss Notice
Hello Guest,

Please reach out to us at admin@speforums.com/+91 8600177662 in case you face any issues with SPEForums. Share your feedback - Click Here

Please support us by sharing performance engineering tutorials/resources with SPEForums.com

-Crew

Script to Create Huge Table for Performance Testing

Create a Table Having 1 Million Rows With Date

  1. admin
    1. Create table in the database

    Code:
    CREATE TABLE speforums_bigtable (
      id            NUMBER(10),
      created_date  DATE,
      lookup_id     NUMBER(10),
      data          VARCHAR2(50)
    );
    upload_2018-11-11_11-4-52.png

    2. Execute following script to create 1000000 rows of data. This may take some time to complete the operation.

    Code:
    DECLARE
      l_lookup_id    NUMBER(10);
      l_create_date  DATE;
    BEGIN
      FOR i IN 1 .. 1000000 LOOP
        IF MOD(i, 3) = 0 THEN
          l_create_date := ADD_MONTHS(SYSDATE, -24);
          l_lookup_id   := 2;
        ELSIF MOD(i, 2) = 0 THEN
          l_create_date := ADD_MONTHS(SYSDATE, -12);
          l_lookup_id   := 1;
        ELSE
          l_create_date := SYSDATE;
          l_lookup_id   := 3;
        END IF;
    
        INSERT INTO speforums_bigtable (id, created_date, lookup_id, data)
        VALUES (i, l_create_date, l_lookup_id, 'SPEForums.com sample data for ' || i);
      END LOOP;
      COMMIT;
    END;
    /
    upload_2018-11-11_11-9-12.png


    3. Check if the data was created properly

    Code:
    select count(*) from speforums_bigtable;
    upload_2018-11-11_11-10-35.png