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

Home -> Community -> Usenet -> c.d.o.misc -> Re: problem about Sequence

Re: problem about Sequence

From: Jason Jay Weiland <archduke_at_uclink4.berkeley.edu>
Date: Wed, 28 Oct 1998 08:25:11 -0800
Message-ID: <36374567.ACD9F75C@uclink4.berkeley.edu>


Ken,

     Try using CURRVAL to find maximum number generated from your sequence. You can also get additional details from the USER_SEQUENCE table.

SQL> insert into registration

     values (user_id_seq.NextVal, 'Ken Ho'); 1 row created.

SQL> insert into registration

     values (user_id_seq.NextVal, 'Jay Weiland'); 1 row created.

SQL> select * from registration;

  USER_ID USER_NAME
--------- -----------

        1 Ken Ho
        2 Jay Weiland

SQL> select user_id_seq.CurrVal from dual;

  CURRVAL


        2

SQL> select *
  2 from user_sequences
  3 where sequence_name = 'USER_ID_SEQ';

SEQUENCE_NAME                  MIN_VALUE MAX_VALUE INCREMENT_BY C O
CACHE_SIZE LAST_NUMBER
------------------------------ --------- --------- ------------ - -
---------- -----------
USER_ID_SEQ                            1 1.000E+27            1 N N
20          21


Jay!!!

Ken Ho Kwok Fai 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
Received on Wed Oct 28 1998 - 10:25:11 CST

Original text of this message

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