Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> automatically creating unqiue primary keys with triggers and sequences
Hi,
I'm porting an app from MySQL to Oracle 8 and ask me, if it is possible to use a trigger and a sequence to accomplish the same effect as MySQL's "autoincrement" feature.
In MySQL, when you define a primary key like this:
CREATE TABLE MyTab (
id integer DEFAULT 0 NOT NULL AUTO_INCREMENT,
name char(30),
PRIMARY KEY(id)
);
you can easily do
INSERT INTO MyTab (name) VALUES ('Felix');
without generating a unique primary key.
How can I emulate this with triggers and sequences so that I don't have to change the application?
-Felix Received on Fri May 19 2000 - 00:00:00 CDT