If you know how to edit your code in SQL*Plus, you already know how to do it in SQLcl. But I get asked this a lot, do you support EDIT? Do you support CHANGE? And what does SQLcl offer over those?

So let’s tackle the old and then the new…

C/Old/New

SQL*Plus has the C[HANGE] command.

C[HANGE] sepchar old [sepchar [new [sepchar]]]

Changes the first occurrence of the specified text on the current line in the buffer. The buffer has no command history list and does not record SQL*Plus commands.

We support that.

FETCH FIRST - you know about this nifty 12c syntax, yes?
FETCH FIRST – you know about this nifty 12c syntax, yes?

EDIT filename

It also has the EDIT command.

ED[IT] [file_name[.ext]]

where file_name[.ext] represents the file you wish to edit (typically a script).

Invokes an operating system text editor on the contents of the specified file or on the contents of the buffer. The buffer has no command history list and does not record SQL*Plus commands.

Enter EDIT with no filename to edit the contents of the SQL buffer with the operating system text editor.

We support that.

edit with something in the buffer...
edit with something in the buffer…
you can change it to EMACS if you want to feel special a la DEFINE _EDITOR =  "vi"
you can change it to EMACS if you want to feel special a la DEFINE _EDITOR = “vi”

Inline Editing

SQLcl additionally offers an inline editor.

You can go through your history, find what you want, and then just arrow around the buffer, and make live changes. When you’re ready to execute the statement, you can just hit Ctrl+R.

the '*' shows which line the cursor is on in case you lose track of where you are...
the ‘*’ shows which line the cursor is on in case you lose track of where you are…

Help Edit

[email protected]? >help edit
EDIT
 ---------
 
 Invokes an operation system text editor ON the contents OF the 
specified file OR ON the contents OF the SQL buffer. 
 
 ED[IT] [file_name[.ext]]
 
The DEFINE variable _EDITOR can be used TO SET the editor TO USE
 
IN SQLcl, _EDITOR can be SET TO "inline". This will SET the editor TO
be the SQLcl editor.  This supports the following shortcuts
	^R - Run the CURRENT buffer
	^W - GO TO top OF buffer
	^S - GO TO bottom OF buffer
	^A - GO TO START OF line
	^E - GO TO END OF line
 
[email protected]? >
thatjeffsmith
Author

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

8 Comments

  1. Hi,
    In the age of IPhones and UX, I am quite surprised to see that Oracle is trying to revive sqlplus. It was not user friendly tool and still it is, what would be the reason to spend resources to such a tool?

  2. So, Jeff – SQLcl is cool, but it is still officially an Early Adopter release. It has been EA for a long time – more than a year, I think.

    I’m nervous about encouraging my developers to use anything that isn’t OFFICIALLY a supported product. Is that EVER going to happen for SQLcl?

    • thatjeffsmith

      It’s still in Early Adopter. Yes, it’s been a long time. It will be officially made available soon.

  3. I move between SQL Developer, and SQLcl .
    The command ^R is different in SQLcl
    ^R – Run the CURRENT buffer
    and SQL Developer
    ^R – Relpace
    It would be really nice if F9 in SQLcl could run current buffer as SQL Developer does

  4. Hi Jeff,
    I noticed that using EDIT will create two afiedt.buf files – one in the sqlcl folder (containing the buffer) and one in my user directory (empty). EDIT will always open the empty one in the user directory. Is there any way around this behavior?

    • Lars I have not had this issue but my log login.sql does

      set editf /tmp/sqlbuf.sql

      Actually I dynamically set the name to the session.

Reply To John Cancel Reply