SQL

SQL정리(now(), sysdate(), current_timestamp 차이)

goshek 2024. 9. 26. 15:49

# now(), sysdate(), current_timestamp;

select now() 
, sysdate()
    , current_timestamp;

# now(): 서버의 시간을 가져오는 함수
# sysdate(): 호출되는 시점을 반환
# current_timestamp: now()와 동일 

# 차이점
-- now(), current_timestamp
-- : 실행되는 시점에서 시간이 반환

-- sysdate()
-- : 호출되는 시점의 시간이 반환

select now() 
, sysdate()
    , current_timestamp
    , sleep(5) -- 시간을 지연시키는 함수 (5초 지연)
    , now() 
, sysdate() -- 값이 호출되는 시점이 반환! (혼자 다름)
    , current_timestamp;

'SQL' 카테고리의 다른 글

SQL정리(trigger)  (2) 2024.09.27
SQL정리(동적SQL)  (0) 2024.09.27
SQL정리(StoredProcedure)  (0) 2024.09.26
SQL정리(변수)  (0) 2024.09.26
SQL 정리(형 변환)  (0) 2024.09.26