|
|
1. 12c 쪽에 ts800 이라는 테이블스페이스를 사이즈 100m로 생성하시오
2. 12c 쪽에 hr800 이라는 유저를 만드시오
코드 :
■1. 12c 쪽에 ts800 이라는 테이블스페이스를 사이즈 100m로 생성하시오
--현재 데이터파일/테이블스페이스 확인
select tablespace_name, file_name
from dba_data_files;
-- TS800 테이블스페이스 생성
create tablespace ts800
datafile '/u01/app/oracle/oradata/ora12/ts800.dbf' size 100m;
■2. 12c 쪽에 hr800 이라는 유저를 만드시오
create user hr800 identified by tiger;
grant connect, resource to hr800;
-- 기본 테이블스페이스 지정 및 quota 설정
alter user hr800 default tablespace ts800;
alter user hr800 quota unlimited on ts800;
3. 12c 쪽에 ts800 테이블스페이스에 오늘 배운 SQL*Loader를 이용해서 sales100, products100, times100 테이블을 생성하고 데이터를 입력하시오
--코드 :
--테이블 생성
CREATE TABLE sales100 (
prod_id NUMBER, -- 상품 ID
cust_id NUMBER, -- 고객 ID
time_id DATE, -- 판매 날짜 (시간 포함)
channel_id NUMBER, -- 판매 경로 ID
promo_id NUMBER, -- 프로모션 ID
quantity_sold NUMBER, -- 판매 수량
amount_sold NUMBER(10, 2), -- 판매 금액 (소수점 포함)
prod_name VARCHAR2(200) -- 상품명 (추후 업데이트용, 넉넉하게 200자)
);
--컨트롤 파일 생성
options(skip=1)
load data
infile '/home/oracle/sales.csv'
into table sales100
fields terminated by ','
optionally enclosed by '"'
(PROD_ID,CUST_ID,TIME_ID date 'YYYY/MM/DD HH24:MI:SS',CHANNEL_ID,PROMO_ID,QUANTITY_SOLD,AMOUNT_SOLD,PROD_NAME)
----sqlldr 로 데이터 이행
sqlldr hr800/tiger control=sales.txt data=sales.csv direct=y
--테이블 생성
create table products100
( prod_id number(6,0) not null enable,
prod_name varchar2(50 byte) not null enable,
prod_desc varchar2(4000 byte) not null enable,
prod_subcategory varchar2(50 byte) not null enable,
prod_subcategory_id number not null enable,
prod_subcategory_desc varchar2(2000 byte) not null enable,
prod_category varchar2(50 byte) not null enable,
prod_category_id number not null enable,
prod_category_desc varchar2(2000 byte) not null enable,
prod_weight_class number(3,0) not null enable,
prod_unit_of_measure varchar2(20 byte),
prod_pack_size varchar2(30 byte) not null enable,
supplier_id number(6,0) not null enable,
prod_status varchar2(20 byte) not null enable,
prod_list_price number(8,2) not null enable,
prod_min_price number(8,2) not null enable,
prod_total varchar2(13 byte) not null enable,
prod_total_id number not null enable,
prod_src_id number,
prod_eff_from date,
prod_eff_to date,
prod_valid varchar2(1 byte) );
--컨트롤 파일 생성
options(skip=1)
load data
infile '/home/oracle/products.csv'
into table products100
fields terminated by ','
optionally enclosed by '"'
( prod_id,
prod_name,
prod_desc,
prod_subcategory,
prod_subcategory_id,
prod_subcategory_desc,
prod_category,
prod_category_id,
prod_category_desc,
prod_weight_class,
prod_unit_of_measure,
prod_pack_size,
supplier_id,
prod_status,
prod_list_price,
prod_min_price,
prod_total,
prod_total_id,
prod_src_id,
prod_eff_from date 'YYYY/MM/DD HH24:MI:SS',
prod_eff_to date 'YYYY/MM/DD HH24:MI:SS',
prod_valid
)
--sqlldr 로 데이터 이행
sqlldr hr800/tiger control=products.txt data=products.csv direct=y
--테이블 생성
create table times100
( time_id date not null enable,
day_name varchar2(9 byte) not null enable,
day_number_in_week number(1,0) not null enable,
day_number_in_month number(2,0) not null enable,
calendar_week_number number(2,0) not null enable,
fiscal_week_number number(2,0) not null enable,
week_ending_day date not null enable,
week_ending_day_id number not null enable,
calendar_month_number number(2,0) not null enable,
fiscal_month_number number(2,0) not null enable,
calendar_month_desc varchar2(8 byte) not null enable,
calendar_month_id number not null enable,
fiscal_month_desc varchar2(8 byte) not null enable,
fiscal_month_id number not null enable,
days_in_cal_month number not null enable,
days_in_fis_month number not null enable,
end_of_cal_month date not null enable,
end_of_fis_month date not null enable,
calendar_month_name varchar2(9 byte) not null enable,
fiscal_month_name varchar2(9 byte) not null enable,
calendar_quarter_desc char(7 byte) not null enable,
calendar_quarter_id number not null enable,
fiscal_quarter_desc char(7 byte) not null enable,
fiscal_quarter_id number not null enable,
days_in_cal_quarter number not null enable,
days_in_fis_quarter number not null enable,
end_of_cal_quarter date not null enable,
end_of_fis_quarter date not null enable,
calendar_quarter_number number(1,0) not null enable,
fiscal_quarter_number number(1,0) not null enable,
calendar_year number(4,0) not null enable,
calendar_year_id number not null enable,
fiscal_year number(4,0) not null enable,
fiscal_year_id number not null enable,
days_in_cal_year number not null enable,
days_in_fis_year number not null enable,
end_of_cal_year date not null enable,
end_of_fis_year date not null enable );
--컨트롤 파일 생성
options(skip=1)
load data
infile '/home/oracle/times.csv'
into table times100
fields terminated by ','
optionally enclosed by '"'
( time_id date 'YYYY/MM/DD HH24:MI:SS',
day_name,
day_number_in_week,
day_number_in_month,
calendar_week_number,
fiscal_week_number,
week_ending_day date 'YYYY/MM/DD HH24:MI:SS',
week_ending_day_id,
calendar_month_number,
fiscal_month_number,
calendar_month_desc,
calendar_month_id,
fiscal_month_desc,
fiscal_month_id,
days_in_cal_month,
days_in_fis_month,
end_of_cal_month date 'YYYY/MM/DD HH24:MI:SS',
end_of_fis_month date 'YYYY/MM/DD HH24:MI:SS',
calendar_month_name,
fiscal_month_name,
calendar_quarter_desc,
calendar_quarter_id,
fiscal_quarter_desc,
fiscal_quarter_id,
days_in_cal_quarter,
days_in_fis_quarter,
end_of_cal_quarter date 'YYYY/MM/DD HH24:MI:SS',
end_of_fis_quarter date 'YYYY/MM/DD HH24:MI:SS',
calendar_quarter_number,
fiscal_quarter_number,
calendar_year,
calendar_year_id,
fiscal_year,
fiscal_year_id,
days_in_cal_year,
days_in_fis_year,
end_of_cal_year date 'YYYY/MM/DD HH24:MI:SS',
end_of_fis_year date 'YYYY/MM/DD HH24:MI:SS' )
--sqlldr 로 데이터 이행
sqlldr hr800/tiger control=times.txt data=times.csv direct=y
4. 12c 쪽의 ts800 테이블스페이스를 19c 쪽으로 tablespace level로 이행하시오
코드 :
--AS-IS(12c)에서 TS800을 READ ONLY로 변경
connect / as sysdba
select t.name, d.enabled
from v$tablespace t, v$datafile d
where t.ts# = d.ts#;
alter tablespace ts800 read only;
select t.name, d.enabled
from v$tablespace t, v$datafile d
where t.ts# = d.ts#;
--AS-IS(12c)에서 테이블스페이스 레벨 Export (exp)
exp transport_tablespace=y tablespaces=ts800 file=ts800.dmp
--덤프 파일 전송
scp ts800.dmp oracle@192.168.23.152:/home/oracle/
--데이터파일 전송
scp /u01/app/oracle/oradata/ora12/ts800.dbf oracle@192.168.23.152:/home/oracle/oradata/
--TO-BE(19c) 쪽에 사용자 생성
connect / as sysdba
create user hr800 identified by tiger;
grant connect, resource to hr800;
--TO-BE(19c)에서 Import (imp)로 Transportable Tablespace 적용
imp transport_tablespace=y file=ts800.dmp datafiles='/home/oracle/oradata/ts800.dbf'
--(필요 시) TS800을 READ WRITE로 전환
alter tablespace ts800 read write;
5. 이행 결과를 화면 캡처해서 이수자 평가 10번으로 제출하시오
코드 :
--이행 결과 확인 (오브젝트/인덱스)
connect hr800/tiger
select table_name from user_tables;
select index_name from user_indexes;
--개수 확인
select count(*) from SALES100;
select count(*) from PRODUCTS100;
select count(*) from TIMES100;
|
|
