1

我想知道如何限制每天输入数据库表的记录数。我正在使用 Oracle 数据库。我基本上希望用户每小时只输入 1 条记录,如果他们尝试超过该记录,则会抛出错误。任何想法的人?提前致谢。

4

1 回答 1

4

Add two columns to the table: user_id number, timestamp_hour date and

create unique index user_date(user_id, timestamp_hour) on your_table

And then:

insert into table values (your_columns, user_id, trunc(sysdate, 'hh'));

If the user tries to add a second record in the same hour will get an exception.

于 2012-11-07T18:40:18.907 回答