Sub topic 7
Installing and Starting SQLcl
SQLcl is Oracle’s command-line interface for SQL and PL/SQL. It is useful when you prefer a terminal, need repeatable scripts, or want to run database work from automation. This chapter assumes that you know basic SQL, can use a terminal, and have access to an Oracle Database account. It does not require an active database connection yet.
What SQLcl needs
SQLcl runs on Java. Use a supported Java runtime, or use a SQLcl package that includes the required Java runtime. Check your Java installation before installing SQLcl:
java -versionA successful command prints the installed Java version. If the command is not found, install a supported Java runtime or choose a SQLcl download that bundles one.
Download SQLcl from Oracle and extract the archive into a directory that you control. For example:
Linux or macOS: /opt/sqlcl
Windows: C:\Tools\sqlclThe extracted directory contains a bin directory. The SQLcl executable is inside that directory.
Put SQLcl on your PATH
PATH is the list of directories that your operating system searches for commands. Adding SQLcl's bin directory to PATH lets you run sql from any directory.
On Linux or macOS, add the following line to your shell startup file, such as ~/.bashrc or ~/.zshrc:
export PATH="/opt/sqlcl/bin:$PATH"Reload the file and check SQLcl:
source ~/.bashrc
sql -versionUse the appropriate startup file for your shell. If you extracted SQLcl elsewhere, replace /opt/sqlcl/bin with that path.
On Windows, add the SQLcl bin directory through System Properties > Environment Variables > Path. Open a new Command Prompt or PowerShell window, then run:
sql -versionThe command should print the SQLcl release and its Java information. If the shell still cannot find sql, check the extraction path and confirm that you opened a new terminal after changing PATH.
Start SQLcl without connecting
You can start SQLcl without selecting a database. This is useful when you want to inspect the client, prepare commands, or enter credentials interactively later.
sql /nologSQLcl displays a prompt similar to this:
SQLcl: Release 25.x Production
SQL>At this point, SQLcl is running, but there is no database session. The /nolog option prevents SQLcl from attempting an automatic login. You can leave SQLcl with:
exitThe normal startup path looks like this:
flowchart TD
A[Install supported Java] --> B[Download and extract SQLcl]
B --> C[Add SQLcl bin to PATH]
C --> D[Run sql -version]
D --> E[Start SQLcl with sql /nolog]
E --> F[SQL prompt appears]The client must start successfully before connection problems can be diagnosed. If sql -version fails, fix the local Java, PATH, or installation issue first. Database errors occur only after SQLcl has started and attempts to connect.
Exercise
What should you check first if the terminal reports that the sql command is not found?
Show answer
Check that SQLcl was extracted, that its bin directory is on PATH, and that the terminal was reopened after PATH changed.