Skip to content

Instantly share code, notes, and snippets.

@davidhooey
Created September 5, 2013 14:51
Show Gist options
  • Save davidhooey/6451214 to your computer and use it in GitHub Desktop.
Save davidhooey/6451214 to your computer and use it in GitHub Desktop.
Oracle Create Skewed Table With ID
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