1.CREATE TABLE HR.RTABLE ( RID NUMBER PRIMARY KEY, NOTES VARCHAR2(20));
2.create a procedure that will populate the table.
CREATE PROCEDURE HR.POPULATE_RTABLE ( N NUMBER )
IS
/* this procedure inserts N records into RTABLE */
V INTEGER;
BEGIN
-- get the maximum ID from the table
SELECT MAX(RID) INTO V FROM RTABLE;
FOR I IN 1..N LOOP
INSERT INTO RTABLE (RID, NOTES) VALUES(I, 'record ' || TO_CHAR(I));
-- end the transactions every 5 inserts
IF MOD(I,5)=0 THEN
COMMIT;
END IF;
END LOOP;
COMMIT;
END POPULATE_RTABLE;
/
IS
/* this procedure inserts N records into RTABLE */
V INTEGER;
BEGIN
-- get the maximum ID from the table
SELECT MAX(RID) INTO V FROM RTABLE;
FOR I IN 1..N LOOP
INSERT INTO RTABLE (RID, NOTES) VALUES(I, 'record ' || TO_CHAR(I));
-- end the transactions every 5 inserts
IF MOD(I,5)=0 THEN
COMMIT;
END IF;
END LOOP;
COMMIT;
END POPULATE_RTABLE;
/
13. Populate the testing table with a few thousands rows.
SQL> exec HR.POPULATE_RTABLE ( 10000 )
SQL> SELECT COUNT(*) FROM HR.RTABLE ;
No comments:
Post a Comment