db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernd Ruehlicke" <BRuehli...@lgc.com>
Subject RE: can derby have a "sequence" column?
Date Sat, 17 Sep 2005 17:00:50 GMT
Each column has the option to have a identity column which automatically
increases a counter if a row is inserted.


.. here a section of a JUnit test of mine using this ..
    ...
          Statement s = _connection.createStatement();
          /*
             We create a table, add a few rows, and update one.
           */
          s.execute("create table "+testTable1+"(seq bigint not null
generated always as identity (start with 1, increment by 1), dummy
varchar(1))");
         System.out.println("Created table "+testTable1);
         s.execute("insert into "+testTable1+" (dummy) values('a')");
         s.execute("delete from  "+testTable1+" where dummy='a'");
         System.out.println("Inserted to  "+testTable1);
         String skey = stringQuery(_connection,"values
IDENTITY_VAL_LOCAL()");
         System.out.println("Derby: created DUAL: "+skey);
  ...

The IDENTITY_VAL_LOCAL gives you the latest number assigned


About the concept of a global seaquence generate please vote for
http://issues.apache.org/jira/browse/DERBY-103

Bernd 

> -----Original Message-----
> From: Mag Gam [mailto:magawake@gmail.com] 
> Sent: Saturday, September 17, 2005 8:38 AM
> To: Derby Discussion
> Subject: Re: can derby have a "sequence" column?
> 
> how do you get the last serial used in a table?
> 
> 
> 
> 
> On 9/16/05, Jean T. Anderson <jta@bristowhill.com> wrote:
> 
> 	firstname lastname wrote:
> 	> If I remember correctly, Oracle can define a column as being a
> 	> "sequence", which is a garaunteed unique integer for 
> each record. Can
> 	> derby do this? A create table example would be nice. 
> 	
> 	Derby supports generated "identity" columns; examples are here:
> 	
> 	   http://db.apache.org/derby/docs/10.1/ref/rrefsqlj37836.html 
> 	
> 	regards,
> 	
> 	-jean
> 	
> 
> 
> 
----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information
for the sole use of the intended recipient.  Any review, use, distribution, or disclosure
by others is strictly prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the sender by reply e-mail
and delete all copies of this message.

Mime
View raw message