Re: problem about Sequence

From: <prochak_at_my-dejanews.com>
Date: Wed, 28 Oct 1998 19:17:32 GMT
Message-ID: <717qkd$2ld$1_at_nnrp1.dejanews.com>


Ken,

 what's wrong with selecting it from the table? In your case, it is a primary key, which means it automatically has an index. Picking the max value from the index is very quick.

select max(user_id) from registration ;

Don't forget to analyze your table after updates!

update.....
analyze table registration compute statistics; (Note if the updates are in a loop, do the analyze after the loop).

If you are getting slow response for the MAX() I'll bet it's because you didn't analyze the table.

Good luck!

   ed

In article <7176an$5kg_at_eng-ser1.erg.cuhk.edu.hk>,   Ken Ho Kwok Fai <kfho_at_cse.cuhk.edu.hk> wrote:
> I made a sequence in a table "test" by the following SQL:
>
> ============================================================
> create table registration
> (user_id number NOT NULL primary key,
> user_name varchar2(11)
> );
>
> create sequence user_id_seq start with 1 increment by 1 nocycle;
> =============================================================
>
> After I insert some values to the table, how could I know the
> max sequence number? Is there a table to store the sequence? I don't want
> to select it from the table and the compare the largest number as it
> needs a lot of time. Any method that could allow me to get the max
> sequence number? Thanks a lot.
>
> --
> Regards,
> Ken Ho
>

--
Ed Prochak
Magic Interface, Ltd.
440-498-3702

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
Received on Wed Oct 28 1998 - 20:17:32 CET

Original text of this message