Mostly Making oracle easy, mostly:
  • Deploy updates to multiple Oracle Databases, concurrently
  • Getting started with Oracle Database CI/CD & SQLcl Projects
  • SQLcl Projects: Automating Oracle Database app deployments
  • Connecting to Oracle using VS Code & Kerberos Auth
  • How to Export all of your Oracle Database REST APIs
  • Organize VS Code Database Environments: Connection Folders
  • SQL Developer for VS Code 25.1: Connection Folders are here!
  • Secure IOT device uploads to Oracle Database via REST API
Search for:
  • X (Twitter)
  • YouTube
  • LinkedIn
ThatJeffSmith ThatJeffSmith
  • SQLDev / VS Code
  • SQLDev Web
  • REST APIs
  • Data Modeling
  • Ask A Question
  • About
  • Search for:
In SQL Developer

Setting Default Script Execution Directory in SQLcl

April 29, 2015 2 Mins Read

We have a script execution directory setting in SQL Developer…but what about our new SQLcl command line utility?

That was a question posed to me this morning.

My answer was..well, let me show you my answer.

Here's where I'm at, directory-wise as I get set to launch SQLcl
Here’s where I’m at, directory-wise as I get set to launch SQLcl
I'm in, and I go to execute my employees.sql script
I’m in, and I go to execute my employees.sql script
But wait, where is it getting the employees.sql script from exactly?
But wait, where is it getting the employees.sql script from exactly?
Oh yeah...what's in there?
Oh yeah…what’s in there?
┌─[16:31:49]─[wvu1999]─[MacBook-Air-Smith]:~/sqlclNEW$
└─>cat login.sql
SET sqlprompt "_user '@' _connect_identifier >"
SET sqlformat ansiconsole
cd /Users/wvu1999/scripts
┌─[16:31:57]─[wvu1999]─[MacBook-Air-Smith]:~/sqlclNEW$
└─>

Now you can see why:

  • My prompt is what it is
  • My output is formatted nicely
  • My script is able to be found

In Case This is All New to You…

SQLcl is a new take on SQL*Plus brought to you by the SQL Developer team.

CD is a new command available. From the HELP…

Note we also support the /nolog option :)
Note we also support the /nolog option 🙂

SET SQLFORMAT allows to you predefine your output to JSON, CSV, HTML, INSERTS..and also to set a ANSICONSOLE for pretty coloring and nicer text spacing and formatting.

This works in SQL Developer, too!

Use the CD command to change where the GUI looks for your files to execute AND where files will be written to.

By default, it’s the %user/temp% directory, as supplied by the OS.

note the CD command at the top

When the script engine goes to write the CSV file, it will do so in my c:\users\jdsmith directory. And this $SQLPATH will be maintained for the duration of my SQL Developer instance….until I change it again 🙂

cddirectoryloginscriptsqlclsqlplus
Author thatjeffsmith

I'm a Distinguished Product Manager at Oracle. My mission is to help you and your company be more efficient with our database tools.

  • Website
Prev Post

Install Oracle REST Data Services w/SQL Developer

April 28, 2015 8 Mins Read
Next Post

Defining a RESTful Service in SQL Developer with :BINDS

May 1, 2015 2 Mins Read

Related Posts

Deploy updates to multiple Oracle Databases, concurrently

May 8, 2025

Getting started with Oracle Database CI/CD & SQLcl Projects

May 5, 2025

SQLcl Projects: Automating Oracle Database app deployments

May 5, 2025

14 Comments

  1. Jack 3 years ago Reply

    I use both SQL*Plus and SQLcl. There are some set up commands I use in my login.sql that are conflicting depending on which tool I’m starting. It seems that SQLPATH is used in both. Is there a way to ‘route’ each tool to it’s own location for login.sql (and ONLY login.sql)?

    I don’t want to mess with the “Start in” locations.

    Thanks Jeff.

    • thatjeffsmith Post Author 3 years ago

      Easiest answer is to put the sqlcl login in a place only SQLcl will see it.

    • Jack 3 years ago

      Could you let me know where those ‘only SQLcl’ locations are documented?

      Thank you.

    • thatjeffsmith Post Author 3 years ago

      Show login

      That’ll show you where we look.

    • Jeff 3 years ago

      Thanks Jeff!

      Anyone else checking this thread, look into the SQLPATH and ORACLEPATH environment variables.

      ORACLEPATH relevant to SQL*Plus and SQLPATH to SQLcl.

  2. vladimir 8 years ago Reply

    Hello Jeff,

    how do I set NLS_DATE_FORMAT for sqlcli?
    my query returns NLS_DATE_FORMAT DD-MON-RR, but I’d like to use the db setting, which is YYYY-MM-DD-HH24:MI

    Regards,

    Vladimir

    • thatjeffsmith Post Author 8 years ago

      Alter session set…

    • Jack 3 years ago

      Well, I don’t know quite how I convinced myself earlier that SQL*Plus would ‘respect’ the ORACLEPATH but that is not happening. Both SQL*Plus and SQLcl reference SQLPATH.

      So I’m back to wondering how to get these two tools to look for different versions of LOGIN.SQL…

    • thatjeffsmith Post Author 3 years ago

      Like I said, put it somewhere sqlplus won’t find it, like in the sqlcl bin directory.

      Or just stop using sqlplus…or write a single login script for both. Setting a sqlcl specific property won’t break sqlplus, you’ll just get an unknown cmd response… easily ignored.

  3. Jocke T 9 years ago Reply

    I have a similar problem. In my login.sql I have

    SET sqlprompt “&_user@&_connect_identifier> ”

    Which works fine in SQL*Plus but in SQLcl the prompt doesn’t change from “SQL> ” to my combination.

    If I remove the two ampersands (&) then it works fine in SQLcl but in SQL*Plus I get

    SCOTT@_connect_identifier>

    So not the actual value in _connect_identifer but the string itself.

    After some trail and error, this works in both applications:

    SET sqlprompt “_user’@’_connect_identifier> ”

    /Jocke

  4. Fayyaz 9 years ago Reply

    after downloading the new SQL CLI, I have realized that there is something wrong with the cd command. it doesn’t recongnize “\” it seems. Here are more details:

    22:04:57 starfox:zaheerf@intluaepre> cd c:\mytemp\spool
    CD-001: c:mytempspool is not a directory.
    22:05:38 starfox:zaheerf@intluaepre>

    I tried putting this in login.sql as well but no luck. Any workaround?

    • thatjeffsmith Post Author 9 years ago

      found and fixed, thanks for the report!

  5. Ketan Kothari 10 years ago Reply

    When I am trying to set the sqlprompt, using the below in SQLCL, it does not work. This works fine in SQLPlus.

    column global_name new_value gname
    set termout off
    define gname=idle
    select lower(user) || ‘@’ || instance_name global_name from v$instance;
    select substr(‘&gname@&_CONNECT_IDENTIFIER’,1,48) global_name from dual;
    set termout on
    SET SQLPROMPT ‘&gname> ‘

  6. Rajesh 10 years ago Reply

    After adding the last line to my login.sql file

    login.sql

    column global_name new_value gname
    select lower(user) || ‘@’ ||
    substr( global_name, 1, decode( dot,
    0, length(global_name),
    dot-1) ) global_name
    from (select global_name, instr(global_name,’.’) dot
    from global_name );
    set sqlprompt ‘&gname> ‘
    cd c:\users\179818.CTS

    sql prompt looks good before script execution, but not after. (details below)

    C:\Users\179818.CTS>sql /nolog

    SQLcl: Release 4.1.0 Release Candidate on Thu Apr 30 13:22:25 2015

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

    SQL> conn rajesh/oracle@ora10g
    Connected

    rajesh@ORA10G> select * from dual;

    D
    –
    X

    1 rows selected

    rajesh@ORA10G> @printtbl “select * from dual”

    PL/SQL procedure successfully completed.

    DUMMY : “X”
    —————–

    rajesh@ORAselect * from dual0G>
    rajesh@ORAselect * from dual0G>

Write A Comment Cancel Reply

  • Search this site
  • Don’t miss a single post! Enter e-mail to subscribe.
  • Mostly Making Oracle Easy, Mostly

    Privacy Policy 

  • X (Twitter)
  • YouTube
  • LinkedIn
  • Try our new SQL Developer Extension for VS Code
  • Developer Tools Message Boards

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle. © Jeff Smith and ThatJeffSmith, 2025

Top
ThatJeffSmith