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 05 Nov 2001, Sybrand Bakker <postbus_at_sybrandb.demon.nl>
spake and said:
> 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
Or you can do it in the more 'relationally correct' way:
create table foo
( id int not null primary key ,
col_1 varchar2(64) not null
)
insert into foo ( id , col_1 )
select max(id)+1 id , 'you-value-here' col_1
As they say in the land of Perl, "TMTOWTDI" (There's more than one way to do it).
--Received on Mon Nov 05 2001 - 22:50:53 CST
![]() |
![]() |