Skip to content

Instantly share code, notes, and snippets.

@PaulNeumann
Last active January 30, 2024 10:54
Show Gist options
  • Save PaulNeumann/d541b251e160038412b02d471a3f4704 to your computer and use it in GitHub Desktop.
Save PaulNeumann/d541b251e160038412b02d471a3f4704 to your computer and use it in GitHub Desktop.
SQLcl installation on Windows 10
  1. Add SQLPATH as a user environment variable, pointing to %USERPROFILE%\Documents\Oracle
  2. Add C:\Program Files\SQLcl\bin to system PATH envrionment variable
  3. Rename C:\Program Files\SQLcl\bin\sql.exe to _sql.exe
  4. Copy sql.cmd to C:\Program Files\SQLcl\bin

Note: Portions of sql.cmd are adapted from Oracle's sql.bat, which was used to start older versions of SQLcl on Windows, and from Glen Conway's excellent hints in this thread in the Oracle SQLcl Community.

@ECHO OFF
SETLOCAL
REM *************************************************************
REM SQLcl.cmd
REM
REM Copy this file to the same folder that sql.exe is in
REM *************************************************************
REM =============================================================
REM Set JAVA_HOME folder
REM
REM If the computer has SQL Developer _with the embedded JDK_,
REM SQLcl can use that JDK, if you want it to. Otherwise, point
REM JAVA_HOME to your preferred JDK.
REM =============================================================
SET JAVA_HOME=%ProgramW6432%\SQL Developer\jdk\jre
rem SET JAVA_HOME=%ProgramW6432%\Java\jdk-13
REM =============================================================
REM Set SQLPATH folder
REM
REM If the SQLPATH environment variable is set, and the SQLPATH
REM folder contains a login.sql, SQLcl will run it.
REM =============================================================
SET SQLPATH=%USERPROFILE%\Documents\Oracle
REM =============================================================
REM Set TNS_ADMIN folder
REM
REM If you want SQLcl to use a tnsnames.ora file, point the
REM TNS_ADMIN environment variable to the file's folder.
REM =============================================================
SET TNS_ADMIN=%SystemDrive%\Oracle64\instantclient_19_11\network\admin
REM Switch codepage to UTF-8
CHCP 65001 >NUL 2>&1
SET SQL_HOME=%~dp0..
REM add all SQLcl libraries to classpath
SET CPFILE=%SQL_HOME%\lib\dbtools-sqlcl.jar;%SQL_HOME%\lib\*;%SQL_HOME%\lib\ext\*
REM Use internal simple X for awt in
SET STD_ARGS=-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xss10M
"%JAVA_HOME%\bin\java" %STD_ARGS% -cp "%CPFILE%" oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli %*
ENDLOCAL
@swesley
Copy link

swesley commented May 19, 2021

@PaulNeumann
Copy link
Author

@swesley Thanks! I've updated the link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment