函数名 函数详解
current_timestamp 返回当前会话时区中的当前日期:以timestamp with time zone数据类型
current_date 返回当前会话时区中的当前日期
SYSDATE 函数可以得到目前系统的时间
localtimestamp 返回会话中的日期和时间
dbtimezone 返回时区
SESSIONTIMEZONE 返回会话时区
systimestamp

测试:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SQL> alter session set NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS';

Session altered.

SQL> select current_timestamp,localtimestamp,sysdate,systimestamp from dual;

CURRENT_TIMESTAMP
---------------------------------------------------------------------------
LOCALTIMESTAMP
---------------------------------------------------------------------------
SYSDATE
--------------------
SYSTIMESTAMP
---------------------------------------------------------------------------
27-SEP-20 03.42.56.895320 PM +08:00
27-SEP-20 03.42.56.895320 PM
27-SEP-2020 15:42:56
27-SEP-20 03.42.56.895316 PM +08:00


SQL> alter session set time_zone='-5:00';

Session altered.

SQL> select current_timestamp,localtimestamp,sysdate,systimestamp from dual;

CURRENT_TIMESTAMP
---------------------------------------------------------------------------
LOCALTIMESTAMP
---------------------------------------------------------------------------
SYSDATE
--------------------
SYSTIMESTAMP
---------------------------------------------------------------------------
27-SEP-20 02.43.39.911368 AM -05:00
27-SEP-20 02.43.39.911368 AM
27-SEP-2020 15:43:39
27-SEP-20 03.43.39.911363 PM +08:00
  • current_timestamp
1
2
3
4
5
6
7
8
9
10
11
12
13
oracle函数 current_timestamp
【功能】:以timestamp with time zone数据类型返回当前会话时区中的当前日期

【参数】:没有参数,没有括号

【返回】:日期


SQL> select current_timestamp from dual;

CURRENT_TIMESTAMP
---------------------------------------------------------------------------
27-SEP-20 10.30.57.999511 AM +08:00
  • current_date
1
2
3
4
5
6
7
8
9
10
11
12
oracle函数 current_date
【功能】:返回当前会话时区中的当前日期

【参数】:没有参数,没有括号

【返回】:日期

SQL> select current_date from dual;

CURRENT_D
---------
27-SEP-20
  • sysdate
1
2
3
4
5
6
SYSDATE函数可以得到目前系统的时间,例如:
SQL> select sysdate from dual;

SYSDATE
---------
27-SEP-20
  • localtimestamp
1
2
3
4
5
6
7
8
9
10
11
12
【功能】:返回会话中的日期和时间

【参数】:没有参数,没有括号

【返回】:日期


SQL> select localtimestamp from dual;

LOCALTIMESTAMP
---------------------------------------------------------------------------
27-SEP-20 10.42.36.829529 AM
  • dbtimezone
1
2
3
4
5
6
7
8
9
10
11
【功能】:返回时区

【参数】:没有参数,没有括号

【返回】:字符型

SQL> select dbtimezone from dual;

DBTIME
------
+00:00
  • sessiontimezone
1
2
3
4
5
6
7
8
9
10
11
【功能】:返回会话时区

【参数】:没有参数,没有括号

【返回】:字符型



【示例】select dbtimezone,SESSIONTIMEZONE from dual;

返回:+00:00 +08:00
  • systimestamp
1
2
3
4
5
6
7
8
SQL> select current_timestamp,systimestamp from dual;

CURRENT_TIMESTAMP
---------------------------------------------------------------------------
SYSTIMESTAMP
---------------------------------------------------------------------------
27-SEP-20 10.49.23.885829 AM +08:00
27-SEP-20 10.49.23.885806 AM +08:00