如何将INSERTS复制到单独的表中? [英] How to duplicate INSERTS into a separate table?

查看:152
本文介绍了如何将INSERTS复制到单独的表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装的iPhone应用程序使用SQLite数据库来记录在其上执行了基本INSERTS和DELETES的条目。

An iPhone application I have installed uses an SQLite database to log entries with basic INSERTS and DELETES being performed on it.

但是,我希望保留一个永久日志INSERTS对这个表进行,所以当一个INSERT发生时,我想把它写入另一个表,以便创建一个日志。

However I wish to keep a permanent log of the INSERTS made to this table, so when an INSERT occurs, I want it to be written to another table also so as to create a log.

我没有访问应用程序源代码以修改所生成的SQL语句,但我确实可以访问SQLite数据库。

I don't have access to the application source code in order to modify the SQL statements made, but I do have access to the SQLite database.

我可以使用触发器吗?

Can I do this with triggers? If so can somebody provide a short example.

推荐答案

从未使用过SQLite,但这里是google的第一个链接: http://www.sqlite.org/lang_createtrigger.html

Never used SQLite, but here is the first link from google: http://www.sqlite.org/lang_createtrigger.html

您可以这样写:

CREATE TRIGGER duplicate_insert INSERT ON myTable
    BEGIN
        INSERT INTO myDuplicateTable
        VALUES(new.Id, new.Name, new.LastModified)
    END;

HTH

这篇关于如何将INSERTS复制到单独的表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆