Created
September 5, 2013 14:38
-
-
Save davidhooey/6451017 to your computer and use it in GitHub Desktop.
Oracle Create Million Row Table With Unique ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table million; | |
drop sequence million_sequence; | |
create table million | |
( | |
id number, | |
type varchar2(50), | |
constraint million_id_pk primary key (id) | |
); | |
create sequence million_sequence start with 1 nocycle; | |
declare | |
rows_inserted number := 0; | |
begin | |
loop | |
insert into million(id, type) | |
values(million_sequence.nextval, dbms_random.string('U', 1)); | |
rows_inserted := rows_inserted + 1; | |
exit when rows_inserted = 1000000; | |
end loop; | |
commit; | |
end; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment