SQL-Developer: Using macros

Are you missing the feature to record and playback a macro in SQL-Developer?
Well, it’s there, just a bit hidden!

[Update: If you use SQL Developer version 4.01 or newer please read this post: Using macros – Update for version 4.01 ++]

Activate the macro functions

  1. Select “Tools/Preferences” from the main menu.
  2. Select “Shortcut Keys” in the list on the left.
  3. Enter “macro” the right search field.
  4. Assign “Ctrl+Period” to “Macro Playback”. Period is the “.” key on your keyboard.
  5. Assign “Ctrl+Shift+Period” to “Macro Toggle Recording”.

Record a macro

To start the recording of the macro, use an editor window of SQL-Developer and press the keys control (ctrl), shift and period (.) together.
The status bar on the bottom shows “Keystroke recording started.”

Any key you will press from now on will be recorded for replay through this macro.

When you are done press the keys control (ctrl), shift and period (.) together again.
The status bar on the bottom shows “Keystroke recording ended.”

There is only one drawback: You can only have one macro at a time. When you record a new macro the previous macro is gone!

Use the macro

Just press the keys control (ctrl) and period (.) together and your macro gets played back.

Example

Adding quotes and commas to a list
Ever wanted the get rid of manually adding quotes and commas to a list of strings?
With a macro it is easy to get from this:

Item 01
Item 02
Item 03

Item 99

to this:

‘Item 01′,
‘Item 02′,
‘Item 03′,

‘Item 99′,

Here is how:

  1. Go to the first line of the list.
  2. Start the recording by pressing the keys control (ctrl), shift and period (.) together.
  3. Press the following keys (pos1) (‘) (end) (‘) (,) and (“arrow down”) one after each other.
  4. End the recording by pressing the keys control (ctrl), shift and period (.) together again.
  5. Play back the macro by pressing the keys control (ctrl) and period (.) together.
  6. Repeat step 5 until the list is done.
About these ads

11 thoughts on “SQL-Developer: Using macros

    • Well, I use several tools like Excel, UltraEdit, JEdit and others for certain tasks too. But for some small tasks it’s handier and often faster to just record a manual process as a macro and repeat it. It takes a little practice, but it’s sure worth the time saved.

  1. hi Matthias Schulz,
    i need info, connect macro to sql developer for fetching data
    is it possible so we need any extra addins to establish connection.
    support is worthwile for reducing lot of human efforts in my work

    thanks in advance

      • Thank you Matthias! I was looking for the recording ability. Is there a way to view, edit, export and import the generated code so you can share and swap out macros without re-recording from scratch?

      • Hello Ben!
        That is a real good question and would like to know the answer myself.
        The macro feature is inherited from JDeveloper and not documented for SQL-Developer – so it’s hard to find out more.

      • In that case do you know of a way to export a table, or better yet a view (I need sorting), data only, to a specific file path, as insert statements, from the command line or some simpler way than walking through all the dialogs to do so? I have a lengthy migration process I need to simplify and automate more before handing it off.

  2. I just upgraded to Sql Developer 4.01 and I can’t find it. Typing “macro” in the search window brings up *nothing*. Did they remove it from the latest version?

  3. Pingback: SQL-Developer: Using macros – Update for version 4.01 ++ | Oracle Deli

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s