본문 바로가기

Database/Oracle

18 - [Oracle 19C] saving and running scripts

 

sqlplus 에서 스크립트 저장 및 실행하는 방법

 

[oracle@test ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 15 22:57:10 2023
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
orcl


SQL> save test.sql
Wrote file test.sql

SQL> @test.sql

INSTANCE_NAME
----------------
orcl

SQL>

 

 

[oracle@test ~]$ cat test.sql
select instance_name from v$instance
/
[oracle@test ~]$

 

 

 

sqlplus 외부, 서버에서 직접 스크립트 실행하는 방법

 

[oracle@test ~]$
[oracle@test ~]$ sqlplus sys/Manager123#@orcl as sysdba @test.sql

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 15 23:03:11 2023
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0


INSTANCE_NAME
----------------
orcl

SQL>