Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
1 日あたり db テーブルに入力されるレコード数を制限する方法を知りたいです。Oracle データベースを使用しています。私は基本的に、ユーザーが 1 時間に 1 レコードのみを入力し、それを超えようとするとエラーをスローすることを望んでいます。アイデアはありますか?前もって感謝します。
user_id number, timestamp_hour date テーブルに2 つの列を追加します。
user_id number, timestamp_hour date
create unique index user_date(user_id, timestamp_hour) on your_table
その後:
insert into table values (your_columns, user_id, trunc(sysdate, 'hh'));
ユーザーが同じ時間に 2 番目のレコードを追加しようとすると、例外が発生します。