我的数据库中有两个表:
现在,当删除或添加第一列中的房间号时,我的第二个表也应该更新。我认为这可以通过 TRIGGER 命令实现,但我不太确定如何使用它。
一般来说我的创建数据库语句是这样的:
private static final String DATABASE_CREATE_PATIENT_ID_TABLE =
"create table " + DATABASE_PATIENT_TABLE +
" (_id integer primary key autoincrement,"
+ "patient_number text not null, room_numbertext not null, " +
"patient_initial text not null);";
现在,当第一个表中的房间被删除或添加时,我的第二个表应该更新。
private static final String DATABASE_CREATE_NOTES_ID_TABLE =
"create table " + DATABASE_NOTES_TABLE +
" (_id integer primary key autoincrement," +
" room_number text not null, time_hour text not null, " +
"notes_hour text not null, today_date text not null);";
最初我所做的是比较两个表的内容。但是当数据增加时,这肯定会导致性能问题。所以我偶然发现了 TRIGGER 的事情。我认为这可以解决我的问题,但我不知道我到底应该如何使用它。
我是从在 Android 中使用 SQLite 数据库.
我在另一个问题中用屏幕截图解释了这个问题。请看一下,如果请指导我
新问题