코드 :
--오늘의 자습 시간 문제_2026년 1월 19일
--오늘의 마지막 문제1. 아래의 환경을 만들고 no 에는 primary 제약을 걸고
--sex 는 bitmap 인덱스를 생성하세요
select * from insurance;
create table insurance2
as
select rownum as no, i.*
from insurance i ;
select * from insurance2;
select *
from insurance2
where no = 16 and sex = 'female';
-- no 에는 primary 제약
alter table insurance2 add constraint insurance2_no_pk primary key(no);
--sex 는 bitmap 인덱스를 생성
create bitmap index insurance2_sex_bitmap on insurance2(sex);
코드 :
--오늘의 마지막 문제2. 아래의 SQL의 인덱스를 성별의 인덱스를 타겠금 힌트를 주시오.
--( 이수자 평가 제출물 2번째 제출물)
select /*+ no_index(insurance2 insurance2_no_pk) index(insurance2 insurance2_sex_bitmap) */ *
from insurance2
where no = 16 and sex='female';
select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
코드 :
--오늘의 마지막 문제3. insurance2 테이블을 IOT 로 구성해서 일반 힙테이블과 성능상의 차이를 비교하시오
--(이수자 평가 제출물 3번째 제출물)
--테이블 생성
CREATE TABLE insurance2_IOT (
NO NUMBER NOT NULL,
AGE NUMBER(10) ,
SEX VARCHAR2(10) ,
BMI NUMBER(10,2) ,
CHILDREN NUMBER(10) ,
SMOKER VARCHAR2(10) ,
REGION VARCHAR2(20) ,
EXPENSES NUMBER(10,2) ,
CONSTRAINT PK_insurance2_IOT PRIMARY KEY(NO) -- IOT는 PK 필수
)
ORGANIZATION INDEX;
--데이터 삽입
insert into insurance2_IOT
select * from insurance2;
--일반
select *
from insurance2
where no = 16;
select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
--IOT
select *
from insurance2_iot
where no = 16;
select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));