Created
September 5, 2013 14:51
-
-
Save davidhooey/6451214 to your computer and use it in GitHub Desktop.
Oracle Create Skewed Table With 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 skewed; | |
drop sequence skewed_sequence; | |
create table skewed | |
( | |
id number, | |
type varchar2(50), | |
constraint skewed_id_pk primary key (id) | |
); | |
create sequence skewed_sequence start with 1 nocycle; | |
-- Create 500,000 rows with type='MANY' | |
declare | |
rows_inserted number := 0; | |
begin | |
loop | |
insert into skewed(id, type) | |
values(skewed_sequence.nextval, 'MANY'); | |
rows_inserted := rows_inserted + 1; | |
exit when rows_inserted = 500000; | |
end loop; | |
commit; | |
end; | |
/ | |
-- Create 50 rows with type='FEW' | |
declare | |
rows_inserted number := 0; | |
begin | |
loop | |
insert into skewed(id, type) | |
values(skewed_sequence.nextval, 'FEW'); | |
rows_inserted := rows_inserted + 1; | |
exit when rows_inserted = 50; | |
end loop; | |
commit; | |
end; | |
/ | |
create index skewed_type on skewed(type); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment