Timestamp field as primary key
190237Feb 12 2003 — edited Feb 12 2003Hello,
I am dealing with a "log" table to record accesses by end users to different objects. Information to be recorded is user_id, access_time and object_id. Even if it is not really needed, I would like to define a primary key for this table.
Before knowing about the timestamp datatype in Oracle 9i I was thinking on using a sequence to get the value for the log_id field (PK). Now that I have seen how timestamp and systimestamp work I am wondering about the convenience of declaring the PK on the access_time field, timestamp datatype and systimestamp as default value.
The DDL for this table would look like:
create table log (
access_time timestamp default systimestamp,
user_id varchar2(15) not null,
object_id varchar2(15) not null,
constraint log_pk primary key (access_time)
);
The insert DML would be then something like:
insert into log (user_id, object_id) values ('user1', 'object1');
The question is about the convenience of declaring the PK on the timestamp field. Is that OK or would it be preferable (safest) to use the sequence for the PK?
Thanks in advance,
Manuel