DBMS/Oracle

리눅스 schema

JWJ_Hub 2023. 4. 13. 09:51

[root@localhost ~]#  wget https://github.com/oracle-samples/db-sample-schemas/archive/refs/tags/v21.1.tar.gz
[root@localhost ~]#  tar xf v21.1.tar.gz
[root@localhost ~]#  pwd

[root@localhost ~]#  cd /opt/oracle/product/21c/dbhomeXE/demo/schema

[root@localhost schema]#  cd human_resources

[root@localhost human_resources]#  gedit hr_main.sql


hr_main.sql에서 찾아서 바꾸기 메뉴 눌러서 변경할 부분을 입력하고 모두 바꾸기


__SUB__CWD__를
?/demo/schema로 모두 바꾸기

주의 한개만 바꾸는게 아니라 __SUB__CWD__가 있는 곳 모두 바꿔야 합니다


@__SUB__CWD__/schema/human_resources/hr_analz를

@?/demo/schema/human_resources/hr_analz로 변경이 되어야 함


// 위에 바꾸기를 하기 전에 사용 하던 명렁어

sed -t 's/\@__SUB__CWD__/\@?\/demo\/schema/g' hr_main.sql


[root@localhost human_resources]# su - oracle

[oracle@localhost ~]$ . oraenv

[oracle@localhost ~]$ cd $ORACLE_HOME

[oracle@localhost ~]$ pwd

[oracle@localhost ~]$ cd demo/schema

[oracle@localhost schema]$ sqlplus / as sysdba


SQL*Plus: Release 21.0.0.0.0 - Production on Thu Apr 13 10:00:22 2023
Version 21.3.0.0.0

Copyright (c) 1982, 2021, Oracle.  All rights reserved.


Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> alter session set "_oracle_script"=TRUE;

Session altered

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: users

specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp

specify password for SYS as parameter 4:
Enter value for 4: oracle

specify log path as parameter 5:
Enter value for 5: /opt/oracle/product/21c/dbhomeXE/demo/schema/log

specify connect string as parameter 6:
Enter value for 6: localhost:1521/xe