28 Mart 2021 Pazar

NOW() metodu

Giriş
MySQL için açıklaması şöyle
The time returned by NOW(), and other date time functions, is derived from the start time of the query. 
Açıklaması şöyle
Default Timestamps
It is always better to have the two timestamptz fields created_at and updated_at columns with default now() .... Storing what time a record was created or modified would be very useful in the future when going over some analytics or reporting. Audit logs might be required and timestamps are key.
Örnek
Görmek için şöyle yaparız. Burada sleep() olmasına rağmen now() tek select için aynı sonucu veriyor.
MariaDB [test]> select now(),sleep(10),now();
+---------------------+-----------+---------------------+
| now()               | sleep(10) | now()               |
+---------------------+-----------+---------------------+
| 2021-03-22 14:17:05 |         0 | 2021-03-22 14:17:05 |
+---------------------+-----------+---------------------+

Hiç yorum yok:

Yorum Gönder