Objectmix
Tags Register Mark Forums Read

can derby have a "sequence" column? : Apache

This is a discussion on can derby have a "sequence" column? within the Apache forums in Application Servers & Tools category; 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. -- firstname lastname supermail99-97jfqw80gc6171pxa8y+qA @ public.gmane.org -- http://www.fastmail.fm - Send your email first class...


Object Mix > Application Servers & Tools > Apache > can derby have a "sequence" column?

Apache Apache discussions surrounding web server, tomcat, derby, jdo, excalibur, jackrabbit, logging, mina, mod-auth, mod-dav, mod-log, mod-proxy, openjpa, ode, uima and webservices

Reply

 

LinkBack Thread Tools
  #1  
Old 09-16-2005, 08:52 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default can derby have a "sequence" column?

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.
--
firstname lastname
supermail99-97jfqw80gc6171pxa8y+qA@public.gmane.org

--
http://www.fastmail.fm - Send your email first class


  #2  
Old 09-16-2005, 10:18 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: can derby have a "sequence" column?

Yes. For example:

CREATE TABLE GROUPS(
ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (start with 0,
increment by 1),
NAME VARCHAR(25) NOT NULL,
DESCRIPTION VARCHAR(255),
PRIMARY KEY (ID)
)

Regards,
Suavi Demir

At 06:52 PM 9/16/2005, you 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.
>--
> firstname lastname
> supermail99-97jfqw80gc6171pxa8y+qA@public.gmane.org




  #3  
Old 09-16-2005, 10:21 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: can derby have a "sequence" column?

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...sqlj37836.html

regards,

-jean

  #4  
Old 09-17-2005, 08:37 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default 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-N3a1/uIFnjIFraO2wh7vUA@public.gmane.org> 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...sqlj37836.html
>
> regards,
>
> -jean
>


  #5  
Old 09-17-2005, 09:52 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: can derby have a "sequence" column?


Good example but, how do insert a row to this table from JDBC ? Using
ij, it's
just a matter of using the DEFAULT parameter, however, the JDBC
preparedstatement
class has no setDefault() method.

On Fri, 16 Sep 2005 20:18:04 -0700, "Ali Demir" <demir4-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> said:
> Yes. For example:
>
> CREATE TABLE GROUPS(
> ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (start with 0,
> increment by 1),
> NAME VARCHAR(25) NOT NULL,
> DESCRIPTION VARCHAR(255),
> PRIMARY KEY (ID)
> )
>
> Regards,
> Suavi Demir
>
> At 06:52 PM 9/16/2005, you 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.
> >--
> > firstname lastname
> > supermail99-97jfqw80gc6171pxa8y+qA@public.gmane.org

>
>

--
firstname lastname
supermail99-97jfqw80gc6171pxa8y+qA@public.gmane.org

--
http://www.fastmail.fm - Access your email from home and the web


  #6  
Old 09-17-2005, 09:56 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: can derby have a "sequence" column?

The IDENTITY_VAL_LOCAL function returns the most recently assigned number:

http://db.apache.org/derby/docs/10.1...entityvallocal

cheers,

-jean

Mag Gam wrote:
> how do you get the last serial used in a table?
>
>
>
> On 9/16/05, *Jean T. Anderson* <jta-N3a1/uIFnjIFraO2wh7vUA@public.gmane.org
> <mailto:jta-N3a1/uIFnjIFraO2wh7vUA@public.gmane.org>> 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...sqlj37836.html
> <http://db.apache.org/derby/docs/10.1/ref/rrefsqlj37836.html>
>
> regards,
>
> -jean
>
>



  #7  
Old 09-17-2005, 10:15 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: can derby have a "sequence" column?

firstname lastname wrote:

> Good example but, how do insert a row to this table from JDBC ? Using
> ij, it's
> just a matter of using the DEFAULT parameter, however, the JDBC
> preparedstatement
> class has no setDefault() method.


The DEFAULT keyword is part of SQL, not ij. These SQL statements should
all work in JDBC as a PreparedStatement

INSERT INTO GROUPS(ID, NAME, DESCRIPTION) VALUES (DEFAULT, ?, ?)

INSERT INTO GROUPS(NAME, DESCRIPTION) VALUES (?, ?)

INSERT INTO GROUPS VALUES (DEFAULT, ?, ?)

Dan.

>
> On Fri, 16 Sep 2005 20:18:04 -0700, "Ali Demir" <demir4-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> said:
>
>>Yes. For example:
>>
>>CREATE TABLE GROUPS(
>> ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (start with 0,
>>increment by 1),
>> NAME VARCHAR(25) NOT NULL,
>> DESCRIPTION VARCHAR(255),
>> PRIMARY KEY (ID)
>>)


>>




Reply

Thread Tools



All times are GMT -5. The time now is 08:28 AM.

Managed by Infnx Pvt Ltd.