自动在数据库中插入值 [英] Insert value automatically in database
本文介绍了自动在数据库中插入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为income_table
的表,我每个月必须自动插入一行,但是我不知道如何在数据库中自动插入一个值.
I have one table named income_table
and I have to insert one row automatically every month but I don't know how to insert a value automatically in the database.
有什么办法吗?
推荐答案
You can also create a MySQL Event, I believe it's the simplest way nowadays. If you have phpmyadmin, no code is required besides the INSERT
statement:
- 单击要创建事件的数据库,然后在顶部栏上单击事件"链接;
- 通过单击该页面上的按钮打开调度程序;
- 添加一个新事件,然后在弹出窗口中将其设置为"recurring";
- 根据需要选择其余选项;
- 在同一窗口的文本区域中添加插入语句;
- 点击开始"按钮,操作完成!
顺便说一句,该事件生成的代码可以稍后导出,看起来像这样:
Btw, the generated code from that event can be exported later and will look something like this:
CREATE EVENT `monthly`
ON SCHEDULE EVERY 1 MONTH
STARTS '2015-10-07 00:00:00'
ON COMPLETION NOT PRESERVE ENABLE
DO INSERT INTO tbl_name (a,b,c) VALUES(1,2,3);
这篇关于自动在数据库中插入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文