educative.io

Any explanation for the now(), sleep(10), now() in question 2?

Why doest it give the same result?


Course: https://www.educative.io/collection/5352985413550080/6335716377231360
Lesson: https://www.educative.io/collection/page/5352985413550080/6335716377231360/5238030269939712

Hey, @Dmitry_Polovinkin!

I hope you’re doing great. The quiz question checks the understanding of two functions: SYSDATE() and NOW(). The NOW() function returns the time when the query is executed. On the other hand, the SYSDATE() function returns the time when the function is called.

In the following SQL statement, the NOW() function returns the same time because the NOW() function returns the time when the query is executed.

SELECT NOW(), SLEEP(10), NOW(); 

On the other hand, if we call the SYSDATE() function before and after the SLEEP() function. It will return the time when the function is called.

We hope Educative has inspired you to further your learning. Please drop us a note if you have any other questions or concerns.

Happy learning!