Can MySQL handle logic on its own time?

Source: Internet
Author: User
Suppose I now have a table, where one column has a Time field, and I set it to expire in 2015-11-20.
I can write a logical judgment through the MySQL statement, when the server date equals the expiry time, delete the field, can I implement this function?
I now think of the use of MySQL dynamic execution process, but I think this logic for the MySQL server is not good, will produce performance problems, because the general logic of the judgment is implemented through the programming language.

I have to deal with the business logic is-I give my site's member users set a time permission to a certain date, when the member users enter my site, using a script to compare the server current date and I set the expiration date, if expired, delete the user, but it is not very good to write, So I want to use MySQL to judge the time field of the user periodically, and perform the task of deleting user data.

Would like to invite friends to point twos: This can be achieved? What's the impact of doing this?

Reply content:

Suppose I now have a table, where one column has a Time field, and I set it to expire in 2015-11-20.
I can write a logical judgment through the MySQL statement, when the server date equals the expiry time, delete the field, can I implement this function?
I now think of the use of MySQL dynamic execution process, but I think this logic for the MySQL server is not good, will produce performance problems, because the general logic of the judgment is implemented through the programming language.

I have to deal with the business logic is-I give my site's member users set a time permission to a certain date, when the member users enter my site, using a script to compare the server current date and I set the expiration date, if expired, delete the user, but it is not very good to write, So I want to use MySQL to judge the time field of the user periodically, and perform the task of deleting user data.

Would like to invite friends to point twos: This can be achieved? What's the impact of doing this?

Do you want to delete the record or delete the table or change the table structure?

If you delete a record, you can write a script in PHP or shell to check the expiration time, and then remove it.

Scripts can be placed inside the crontab and run once a day.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.