CURRENT_DATE and CURRENT_TIMESTAMP are tied to session time zone
SYSDATE is tied to database server date and time. It can be used querying any table, not just dual, no matter the session nls_date_format chosen
A - false; it is the same only in case database server operating system uses the same time zone as the operating system of the database client (session time zone)
B - false; can be queried in any table, e.g. SELECT emp_no,ename,salary,mgr_no,sysdate FROM emp;
C - true;
SQL> select sys_extract_utc(systimestamp) from dual;
SYS_EXTRACT_UTC(SYSTIMESTAMP)
---------------------------------------------------------------------------
11.09.23 13:58:24,316896
SQL> SELECT SESSIONTIMEZONE FROM DUAL;
SESSIONTIMEZONE
---------------------------------------------------------------------------
+02:00
SQL> SELECT current_date FROM dual;
CURRENT_DATE
--------------------
11-SEP-2023 15:58:41
D - false; sysdate can be used independently of the setting of the NLS_DATE_FORMAT
E - false; sydate returns date and time of the operating system of the database server, current_date returns date and time in the session time zone (i.e. in the time zone of the client)
F - true; both variables returns current time and date set in the session time zone
F cannot be correct:
[oracle@localhost ~]$ cat date_format.sql
alter session set NLS_DATE_FORMAT is set to 'DD-MON-YYYY HH24:MI:SS' ;
select current_timestamp from dual ;
select current_date from dual ;
[oracle@localhost ~]$ sqlplus system/oracle @date_format.sql
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 6 04:39:17 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Wed Apr 06 2022 04:38:02 -04:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
alter session set NLS_DATE_FORMAT is set to 'DD-MON-YYYY HH24:MI:SS'
*
ERROR at line 1:
ORA-00927: missing equal sign
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
06-APR-22 04.39.18.153607 AM -04:00
CURRENT_D
---------
06-APR-22
I think A and C are correct.
SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
SQL> select sysdate,current_date,current_timestamp from dual;
SYSDATE CURRENT_DATE CURRENT_TIMESTAMP
-------------------- -------------------- ---------------------------------------------------------------------------
28-SEP-2021 14:32:48 28-SEP-2021 14:32:48 28-SEP-21 02.32.48.201457 PM +03:00
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions172.htm
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions036.htm
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm
A cannot be correct. Becasue your DB server and your session are in same region, current_date and sysdate are same. If you connect to your DB at another timezone, that command return another result. So....it can be same, but not always do.
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
select current_timestamp from dual;
select current_date from dual;
select sysdate from dual;
08-AUG-21 02.00.13.303335 AM US/PACIFIC
08-AUG-2021 02:00:15
08-AUG-2021 09:00:17
Now check the answers!!!!
if you read the question "where nls_date_format is set to ...."
I have done this and this is the result:
SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
Sesion modificada.
SQL> select sysdate from dual;
SYSDATE
--------------------
17-AGO-2020 17:59:34
SQL> select current_date from dual;
CURRENT_DATE
--------------------
17-AGO-2020 17:59:53
maybe E is correct
SYSDATE also shows time if you change the date display format to include it.
However, A is wrong because SYSDATE shows database resident OS date&time while CURRENT_TIMESTAMP shows session date&time. Different time zones can affect the result.
Not because of this, but because SYSDATE shows database resident OS date&time while CURRENT_TIMESTAMP shows session date&time. Different time zones can affect the result.
It was just an example. You can use any table
SYSDATE is a built-in SQL function available for all users. You can use it anywhere you can use it as any other built-in SQL function.
Ex.
insert into mytable values (..., sysdate, ...);
Sorry A C
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions172.htm
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm
A is wrong.
SYSDATE - returns the current date and time set for the operating system on which the database resides
CURRENT_TIMESTAMP - returns the current date and time in the session time zone
If you have a different time zone set in your session than the time zone set in the database's OS, time will be different
upvoted 1 times
...
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Blob44
3 months, 4 weeks agonautil2
3 months, 4 weeks agofeixiang
1 year, 5 months agodeaf52
10 months, 2 weeks agochandanchoudhary
1 year, 7 months agoAramazd
2 years, 9 months agoryuah
3 years agoeyildiz
3 years, 3 months agoDarrenChenSHCMB
3 years, 2 months agoj_tw
1 year, 9 months agokawsar
3 years, 5 months agokawsar
3 years, 5 months agoama
4 years, 5 months agoama
4 years, 5 months agodanito
4 years, 5 months agoama
4 years, 5 months agoelvegaa
4 years, 2 months agoyou1234
4 years, 6 months agoelvegaa
4 years, 2 months agoama
4 years, 6 months agoNowOrNever
4 years, 6 months agoama
4 years, 5 months agoelvegaa
4 years, 2 months agodanito
4 years, 7 months agodanito
4 years, 7 months agoelvegaa
4 years, 2 months ago