Skip navigation

SQLDeveloper comes with a Command Line Interface called SQLcl.  It is touted as the next SQL*Plus, and is indeed a huge improvement.  Those of you used to rlwrap will be glad to know that command history and recall are now natively built into that CLI.  Here is how to run it on Windows (that is, in a DOS session):

1-CD.jpgFirst cd into a directory where you keep your SQL scripts.  It will then be easier to run them with SQLcl

 

2-DIR.jpgHere you can see I 've got a login.sql file, which will be taken into account by SQLcl, just as SQL*Plus would.  You can also see a few .sql files, which I intend to run from SQLcl.

Here are a few examples of command lines to launch SQLcl:

D:\tools\sqldev\sqldeveloperFR\sqldeveloper\bin\sql myuser@//85.01.20.143:1522/ORCL

D:\tools\sqldev\sqldeveloperFR\sqldeveloper\bin\sql myuser/thepassword@//networkalias:1522/ORCL

D:\tools\sqldev\sqldeveloperFR\sqldeveloper\bin\sql myuser@alias   -- that's an alias from your local tnsnames.ora if you have one.

 

I'm going to connect using a user with little privileges, so I do not mind hard-coding the password in the command line:

3-1stlaunch.jpgAs you can see, I launch SQLcl using its full path, so as to keep my current directory as the working directory.  Since my command-line contains all the required information to find my database and connect to it, running it will connect me and I can start typing SQL  statements straight away.


And since my working directory is the one containing my sql script, I can easily run them like this:

4-COUNTobjects.jpg


So the real boon is that now, we can have our own collection of SQLcl command lines, to either just connect to our favorite databases, or run a script straight away.

D:\tools\sqldev\sqldeveloperFR\sqldeveloper\bin\sql myuser/thepassword@//networkalias:1522/ORCL @activesesss

D:\tools\sqldev\sqldeveloperFR\sqldeveloper\bin\sql myuser/thepassword@//networkalias:1522/BIGDB

D:\tools\sqldev\sqldeveloperFR\sqldeveloper\bin\sql myuser/thepassword@//networkalias:1529/OTHERBIGDB


So now, I can just open a DOS windows, paste those 4 lines of text into it, and be connected to my database of choice within a few seconds, along with the result of a script of mine:


D:

cd D:\tools\sqldev\

D:\tools\sqldev\sqldeveloperFR\sqldeveloper\bin\sql bAW00uiVP/bAW00uiVP@//networkalias:1549/xa13 @countobjects

host title B-UIVP

6-finalCLs.jpg