In Oracle, a DATE
is a binary data type that is stored in the database as 7 bytes (for century, year-of-century, month, day, hour, minute and second). It will ALWAYS have all of those components and is NEVER stored with a particular display format.
Client applications typically have a default human-readable format which they use to display the binary DATE
data to the user; this often defaults to the Oracle session parameter NLS_DATE_FORMAT
and, unfortunately, the default NLS_DATE_FORMAT
does not show the time component of a date.
If you want to change how dates are shown in your session then either change it in your client application or, if it is based on the NLS_DATE_FORMAT
, you can change the format for your current Oracle session using:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS;
Then run:
SELECT SQL_ID,
executions,
LAST_LOAD_TIME,
LAST_ACTIVE_TIME,,
TO_CHAR(ELAPSED_TIME/1000/1000, '999,999,999.000') || ' s' AS TIME,
MODULE,
SQL_TEXT
FROM v$sql
WHERE module = 'JDBC Thin Client'
ORDER BY
LAST_ACTIVE_TIME DESC;
If you want to change how the date is formatted in your query then convert the DATE
to a string using TO_CHAR
:
SELECT SQL_ID,
executions,
LAST_LOAD_TIME,
TO_CHAR(LAST_ACTIVE_TIME, 'YYYY-MM-DD HH24:MI:SS') AS last_active_time,
TO_CHAR(ELAPSED_TIME/1000/1000, '999,999,999.000') || ' s' AS TIME,
MODULE,
SQL_TEXT
FROM v$sql
WHERE module = 'JDBC Thin Client'
ORDER BY
LAST_ACTIVE_TIME DESC
db<>fiddle here