Re: auto_increment

From: Date: Thu, 26 Oct 2000 14:55:08 +0000
Subject: Re: auto_increment
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-3951@lists.php.net to get a copy of this message
> hi, this is more of oracle than php but i'd appreciate > any tips.. how do i make an integer field > auto_incrementing? i used to working with mysql where > 'field int unsigned primary key auto_increment' does > the thing.. thanks for the help. Hi, Oracle doesn't have auto_increment fields : you have to use sequences to make the thing. Try something like CREATE SEQUENCE my_autoinc INCREMENT BY 1 START WITH 1; You can set the beginnig rate as you want. And when inserting into your table do : INSERT INTO test VALUES (my_autoinc.nextval,'bla'); my_autoinc.currval gives you the current value of the sequence. Of course you should make one sequence for each table, if you don't want "holes" in your values ... bye

« previous php.db (#3951) next »