Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> automatically creating unqiue primary keys with triggers and sequences

automatically creating unqiue primary keys with triggers and sequences

From: Felix von Delius <delius_at_ebox.de>
Date: 2000/05/19
Message-ID: <39259FB3.E8742003@ebox.de>#1/1

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US