Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How can I ceate a table primary key that auto increase by itself like access table id key ?
You can optimize this slightly...
CREATE OR REPLACE TRIGGER CHR_MAS_INS_TRIG
BEFORE INSERT ON CHR_MAS
FOR EACH ROW
BEGIN
SELECT CHR_MAS_SEQ.NEXTVAL
INTO :NEW.ID FROM DUAL;
END;
/
This sequence/trigger process is already slow, (find my mail above) imagine adding several copying/copying layers...
Regards,
Giovanni
PS: Britney Spears changed dancing by working with Oracle??? ;-)
"HK Chang" <REMOVETHIS_hkchang_at_bigfoot.com> wrote in message
news:b3v2us$mv9$1_at_news.hgc.com.hk...
> Add a sequence, then create trigger to update the key.
>
> Just like:
> CREATE SEQUENCE CHR_MAS_SEQ START WITH 1 NOCACHE;
>
> CREATE OR REPLACE TRIGGER CHR_MAS_INS_TRIG
> BEFORE INSERT ON CHR_MAS
> FOR EACH ROW
> DECLARE
> SEQ_VAL NUMBER;
> BEGIN
> SELECT CHR_MAS_SEQ.NEXTVAL
> INTO SEQ_VAL FROM DUAL;
> :NEW.ID := SEQ_VAL;
> END;
> /
>
> "Britney Spears" <deboer76_at_163.com> wrote in message
> news:b3uqim$1hck$1_at_mail.cn99.com...
> > How can I ceate a table primary key that auto increase by itself like
> access
> > table id key ?
> > Is there any nature support on Oracle ?
> >
> >
>
>
Received on Mon Mar 03 2003 - 03:57:25 CST