본문 바로가기

데이터베이스

샘플 스키마 HR 설치하기

공부의 목적으로 설치되어 있다는 것은 알 수 있으나 찾아본 바로는 18c 버전 이전에는 자동으로 설치되어 있었지만, 이후 버전부터는 수동으로 설치 작업을 진행해야 한다고 한다. 물론 DBMS 설치시에 설정이 있었겠지만, 본인도 모르게 넘어간 경우를 대비해 설치하는 방법에 대해 작성을 하려고 한다.

 

스키마 다운받기

https://github.com/oracle-samples/db-sample-schemas/releases/tag/v19.2

 

Release Oracle Database Sample Schemas 19.2 · oracle-samples/db-sample-schemas

Use these scripts to create the Oracle Database 19c Sample Schemas referenced in the documentation and examples. The scripts install in Oracle Database 12c and upwards, including Oracle Database Cl...

github.com

현재 RHEL7에서 진행하고 있으며 19c를 사용하고 있다.

tar파일과 zip 파일이 있는데 본인의 리눅스 환경에서 yum을 확인하고 해제가 가능한 파일을 다운받아 준다.

 

다운로드 받은 파일은

[oracle@localhost ~]$ cd $ORACLE_HOME/demo/schema/human_resources

해당 디렉터리로 옮긴 후 파일을 풀어준다.

 

19c 데이터베이스를 실행시킬때 sys 계정으로 접속해준다.

[oracle@localhost human_resources]$ sqlplus / as sysdba

 

아래와 같이 명령어를 입력하는 이유는 12c 이후 버전인 경우

hr계정 생성 시 '올바르지 않은 이름' 오류에 대한 방지를 위함이다.

SQL> alter session set "_oracle_script"=true;

Session altered.

 

@의 역할은 오라클 19c가 설치된 경로를 뜻하며 ?의 역할은 실행을 뜻한다.

(@와 $ORACLE_HOME은 같은 거라고 볼 수 있다.)

SQL> @?/demo/schema/human_resources/hr_main.sql
specify password for HR as parameter 1:
Enter value for 1: [HR 계정에 대한 비밀번호?]

specify default tablespeace for HR as parameter 2:
Enter value for 2: [default tablespeace 대부분 users]

specify temporary tablespace for HR as parameter 3:
Enter value for 3: [temp tablespace 대부분 temp]

specify log path as parameter 4:
Enter value for 4: [로그 저장 디렉토리 선택 : ?/demo/schema/log]

이 외에 환경변수에 따라 SYS 비밀번호 입력도 있고, 접속할 IP:리스너/SID 입력하는 경우도 있다.

이후 스키마에 인덱스 되면서 끝나는 모습을 확인할 수 있다.

이후 DEVELOPER 혹은 리눅스 SQL을 통해서 CONNECT HR/HR로 스키마 접속 후

SELECT * FROM EMPLOYEES; 를 입력하면 샘플 EMPLOYEES 테이블을 확인할 수 있다.