-
PostgreSQL 시간 관련 함수들Software engineer/DB 2025. 7. 11. 10:40
CURRENT_TIMESTAMP,LOCALTIMESTAMP,transaction_timestamp(),now()- transaction 시작된 시각을 반환
- transaction 안에서 여러 번 호출해도 같은 값을 반환
statement_timestamp()- 해당 함수가 포함된 SQL이 실행된 시각을 반환
- 같은 transaction 안이라도, 새로운 SQL 문이 실행될 때마다 값이 갱신
clock_timestamp()- 진짜 현재 시각을 반환
- 같은 문 안에서도 호출 시마다 값이 달라진다.
샘플 쿼리
select CURRENT_TIMESTAMP, LOCALTIMESTAMP, transaction_timestamp(), statement_timestamp(), clock_timestamp(), now() ;참조
공식문서 | https://www.postgresql.org/docs/17/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
9.9. Date/Time Functions and Operators
9.9. Date/Time Functions and Operators # 9.9.1. EXTRACT, date_part 9.9.2. date_trunc 9.9.3. date_bin 9.9.4. AT TIME ZONE and AT LOCAL 9.9.5. …
www.postgresql.org
'Software engineer > DB' 카테고리의 다른 글
Redis: 인메모리 데이터베이스 (7) 2024.10.26