Welcome to Salem Houali ‘s Oracle Developer Notes

Use SQL Developer Command-Line (SQLcl) to run SQL-scripts

SQL Developer Command Line 
SQLcl 18.2

Oracle SQL Developer Command Line (SQLcl) is a free command line interface for Oracle Database. 
You can, both execute in interactive or batch mode, sql and Pl/SQL. It supports all previously written SQL*Plus scripts.
You can download the SQLcl 18.2 here
First, we locate hr_main.sql script on our disk, the script sould be in %ORACLE_HOME%\demo\schema\human_resources.
Then, we modify the script by entering values for some variables as follow:
SET ECHO OFF
SET VERIFY OFF
SET TERM OFF
SET SQLFORMAT default
DEFINE pass=hr
DEFINE tbs=USERS
DEFINE ttbs=TEMP
DEFINE log_path=C:\OraProject\log
DEFINE spool_file = &log_path\hr_main.log
SPOOL &spool_file

Run the command:
@<script_loc>hr_main.sql;
Verify the log:
Connect to HR-schema to view all database-objects created.
or run the following script:
@<script_location>\verif.sql
/*==============================================================*/
-- verif.sql: Verify the HR-schema after main_hr.sql is executed
-- @<script_location>\verif.sql
-- Use SQLCL 18.2 to run the script
-- Author: Salem. Houali
-- Date: 2018.08.26
/*==============================================================*/

SET ECHO OFF
SET VERIFY OFF
SET TERM OFF
SET SQLFORMAT html
DEFINE log_path=<log_dest>\log
DEFINE spool_file = &log_path\hr_main_res.html
SPOOL &spool_file

SELECT OBJECT_NAME,
   OBJECT_TYPE,
   STATUS
 FROM DBA_OBJECTS
WHERE OWNER='HR'
ORDER BY OBJECT_TYPE;
SPOOL OFF
View the html output result:

2 Responses to “Use SQL Developer Command-Line (SQLcl) to run SQL-scripts”

  • Madrueno says:

    This is very attention-grabbing, You are a very skilled blogger. I’ve joined your feed and look forward to in quest of more of your great post. Additionally, I have shared your site in my social networks!

  • Satya says:

    Thank you very much for great article on SQLcl.

    – Satya
    –https://satya-dba.blogspot.com/2019/08/sqlcl-commands-sql-cl-sqlcl.html

Leave a Reply