Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Such a thing as auto increment in oracle?
On Mon, 05 Nov 2001 21:48:18 +1100, Chris Newman
<chris_newman_at_bigpond.com> wrote:
>I am using Oracle version 7 for Windows 95 and want to increment values in a
>column one at a time starting with 1, 2, 3 etc to serve as a primary key.
>MySQL calls this feature auto-increment. How do I do this please
In Oracle you can create auto increment number as an object called 'sequence'.
First create a sequence,
SQL> create sequence my_seq;
this will create a sequence number start with 1 and autoincrement by 1. This is the default, can be changed by specifying.
then while inserting into table...
SQL> insert into t(my_seq.nextval, col2, col3);
you will select the nextval method from the sequence object you have
created.
Every time you select the nextval, the sequence will automatically
increment by 1.
Obviously this is a FAQ. The answer above I copied from www.orafaq.com, but the archives of this group at http://groups.google.com will also show many answers. Please try to search these resources before you start posting a question, which you can assume, has already been answered many times.
Regards
Sybrand Bakker, Senior Oracle DBA
To reply remove -verwijderdit from my e-mail address Received on Mon Nov 05 2001 - 05:13:54 CST
![]() |
![]() |