SQL Developer Trick: Renaming Your Worksheets

thatjeffsmith SQL Developer 16 Comments

Tell Others About This Story:

After a VNC session with the always brilliant @bamcgill, I now know how to rename a worksheet.

Worksheet names are based on the connection name they are attached to

So when you open a worksheet, it’s attached to a database connection. The worksheet name is a property, and it defaults to the connection name. So you DO you have a lot of control over the worksheet name. This is the primary reason I advocate using well thought out names for your connections.

But maybe you want to take a screenshot of a worksheet and not show where you’re connected. Or maybe you have 5 worksheets open and you want to be able to give them a logical name for easier navigation.

Just because there’s no ‘Rename’ available in the worksheet tab context menu, doesn’t mean you can’t do it 🙂

And the Trick Is…

SET worksheetname NAME

Ta-da!

And because I know someone will ask, ‘Yes, you can do this too.’

Single and double-quoting your worksheet names will work

Tell Others About This Story:

Comments 16

  1. Hi Jeff
    Is there a set command that allows to rename a Worksheet Tab. It would be a cool feature in case in a script with several statements you can set specific Tab name for every SQL output.
    Regards
    — Kirill

    1. thatjeffsmith Post
      Author
  2. Hi,

    The SET WORKSHEETNAME behavior seems to have changed in 4.2. When I for example execute the command SET WORKSHEETNAME TEST;, the worksheet name becomes SET WORKSHEETNAME TEST; as opposed to just TEST (like it used to be in 4.1.3.

    Do I need to do something to get the old behavior back?

    Thanks, Marie

    1. thatjeffsmith Post
      Author
        1. I just upgraded to 4.2.0.17 and it works, but not the same as in 4.1.

          Now it is case sensitive and set worksheetname has to be in lower case. Also, you no longer can have the semi colon at the end.

          It works though, so I’m good. Just a little strange that the old syntax doesn’t work any more.

    1. thatjeffsmith Post
      Author

      Just to make sure you’re not missing this, if you mouse over a document, it will show you the connection.

      You can color code your connections such that [email protected] is always colored in RED – so you can add a visual indicator.

      If you want a prompt, you’ll need to use SQL*Plus or SQLcl.

  3. Hi Jeff and thanks for this tricks.

    I tried to include “set workshetname” in my login.sql but when i clic in connections for open SQL Worksheet, this SET doesn’t work.

    But, when i write in SQL WorkSheet this commande :
    set worksheetname &_GNAME
    it work 🙁 [worksheetname change for “[email protected]”]

    I would like the worksheet name change automaticlly.

    Thank for your help.

    SQLDeveloper Version 4.1.0.19 Build MAIN-19.07

    Here is my login.sql

    set serveroutput on
    define _GNAME=idle
    column global_name new_value _GNAME
    select lower(user) || ‘@’ || substr( global_name, 1, decode( dot, 0, length(global_name), dot-1) ) global_name
    from (select global_name, instr(global_name,’.’) dot from global_name );
    set worksheetname &_GNAME
    set timing on
    set sqlformat ansiconsole

    1. thatjeffsmith Post
      Author

      that login script is running before your worksheet opens, and it doesn’t run through the worksheet itself, so you can’t manipulate a worksheet via that mechanism

        1. thatjeffsmith Post
          Author
  4. Hello Jeff,

    is it possible to include variables? I would like to set the name dynamically in a script. The best I get is

    COLUMN tabname NEW_VALUE tabname NOPRINT;
    SELECT ””||USER||TO_CHAR(SYSDATE,’ dd.mm’)||’ Bug 23748”’ tabname
    FROM dual;
    SET WORKSHEETNAME &tabname

    But then the tab is named “SET WORKSHEETNAME ‘MYUSER 16.04 Bug 23748′”
    It’s almost what I want, except for the SET WORKSHEET 🙂

    Version 4.0.3.16

    Regards
    Marcus

      1. thatjeffsmith Post
        Author

Leave a Reply

Your email address will not be published. Required fields are marked *