MySQL

MySQL) now() ์™€ now() on update now() ์ฐจ์ด์ 

567Rabbit 2024. 5. 20. 11:23

 

์ปฌ๋Ÿผ ์„ค์ •์—์„œ,

 

Datatype์„ TIMESTAMP๋กœ ์„ค์ •ํ•˜๊ณ 

 

Default/Expression(๊ธฐ๋ณธ๊ฐ’)์— 

 

now()๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ ์šฉ(apply)ํ•˜๋ฉด CURRENT_TIMESTAMP,

 

now() on update now()๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ ์šฉ(apply)ํ•˜๋ฉด CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

๋ผ๊ณ  ์ž…๋ ฅ๋œ๋‹ค.

 

 

 

 

now()

: CURRENT_TIMESTAMP 

 

= ํ–‰์„ ์ฒ˜์Œ์œผ๋กœ ์‚ฝ์ž…ํ•  ๋•Œ ๊ธฐ๋ณธ๊ฐ’์„ ํ˜„์žฌ ์‹œ๊ฐ„์œผ๋กœ ์„ค์ •ํ•œ๋‹ค

 

 

now() on update now()

: ON UPDATE CURRENT_TIMESTAMP

 

= ํ–‰์„ ์—…๋ฐ์ดํŠธ ํ•  ๋•Œ ๊ธฐ๋ณธ๊ฐ’์„ ์—…๋ฐ์ดํŠธ ๋œ ์‹œ๊ฐ„์œผ๋กœ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ์„ค์ •ํ•œ๋‹ค