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

Home -> Community -> Usenet -> c.d.o.tools -> Re: sequence question

Re: sequence question

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Sat, 28 Jul 2001 10:08:21 +0100
Message-ID: <996311311.10572.1.nnrp-01.9e984b29@news.demon.co.uk>

Your reply may have been intended as
good humour, but it is seriously defective advice, should never be followed, and could mislead a learner - particularly one who has just asked for clarification.

 There is an article on my website which talks about Sequences in some detail,
which may help the original poster clear up any current confusion.

--
Jonathan Lewis

Host to The Co-operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html

Author of:
Practical Oracle 8i: Building Efficient Databases
See http://www.jlcomp.demon.co.uk/book_rev.html

Seminars on getting the best out of Oracle
See http://www.jlcomp.demon.co.uk/seminar.html

Screensaver or Lifesaver: http://www.ud.com
Use spare CPU to assist in cancer research.




Leandro Teixeira wrote in message <9jo0gq$2m7$1_at_venus.telepac.pt>...

>all that was said is true, u can do a
>select max(PK) +1
>from table_name
>
>that would give u always a sequence.... :)
>
>leandro
>
>
>
>"Sudarshan Sampath" <ssampath_at_scr.siemens.com> wrote in message
>news:hG4_6.11146$DW1.462722_at_iad-read.news.verio.net...
>> This question is more to clarify the concept of a sequence.
>>
>> Say I have a table MYTABLE with column (PK NUMBER(10)) filled with
>> rows in the range 10000 - 20000.
>>
>> I have a sequence that I create with the following params:
>>
>> Start With = 10000
>> Increment by = 1
>> Cache = 20
>> Min Value = 10000
>> Max Value = None
>>
>> Let's call this sequence MYSEQ.
>>
>> Now, if I referenced this sequence in my application with (MYSEQ.NEXTVAL)
to
>> insert
>> a row in the table MYTABLE, would it give me a value 20001?
>>
>> insert into MYTABLE (PK)
>> values
>> (MYSEQ.NEXTVAL);
>>
>> Would this insert a new row with PK = 20001? Or would it give me an error
>> till the sequence value
>> is incremented until 20001? Does a primary key implicitly mean that the
>> sequence we use against it
>> will return a unique value for that table?
>>
>> I am merely trying to understand how the sequence works.
>>
>> Thanks,
>>
>> -Sudarshan
>>
>>
>
>
Received on Sat Jul 28 2001 - 04:08:21 CDT

Original text of this message

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