Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Developer- Session startup script

I would like to have every session in my SQL Developer to be set to the GMT timezone. Is there a way to setup a session startup script in SQL Developer for this?

like image 380
museshad Avatar asked May 05 '14 16:05

museshad


1 Answers

You can create a script file, e.g. C:\Temp\startup.sql, containing:

alter session set time_zone = 'GMT';

Then go to the Preferences, from the Tools menu, and go to the top-level Database item in the panel on the left, and put the path to your file in 'filename for connection startup script' text box:

enter image description here

You can change other settings in your script as well, if they can't be set in the Preferences->Database->NLS section.

The settings are only picked up when you open a new connection - they don't seem to be reapplied when you reconnect or when you open a new SQL Worksheet under an existing connection.

When you connect the 'script output' window will say:

session SET altered.

In 4.0.1 anyway, but apparently not in 4.0.2; and if you then do something like:

select current_timestamp from dual;

then you'll see the GMT time regardless of your PC's locale settings:

CURRENT_TIMESTAMP                 
-----------------------------------
06-MAY-14 11.23.42.593143000 GMT    

with the script, versus in my case this without:

CURRENT_TIMESTAMP                 
-----------------------------------
06-MAY-14 12.25.09.925466000 EUROPE 
/LONDON        

This is tested in version 4.0.1.14 and 4.0.2.15; I think it's always been possible but I'm not able to check previous versions.

like image 154
Alex Poole Avatar answered Dec 06 '22 03:12

Alex Poole