Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use SEQUENCE in Apache Derby?

I'd like to use SEQUENCE support in Apache Derby 10.7. I've created the sequence with the following statement:

CREATE SEQUENCE SAMPLE_SEQ AS INT MAXVALUE 999999 CYCLE;

How can I select next/current value from the SAMPLE_SEQ? Could you please help me out with the query?

like image 840
Tomasz Błachowicz Avatar asked Apr 20 '11 10:04

Tomasz Błachowicz


People also ask

What is sequence in Netezza?

A sequence is a database object from which multiple users can generate unique integers. To create specific sequences, do the following: To create an ascending sequence that increments to its maximum data type value, omit the MAXVALUE or specify NO MAXVALUE.

What is sequence in Pgadmin?

A sequence generates unique values in a sequential order (not necessarily contiguous). The Sequence dialog organizes the development of a sequence through the following dialog tabs: General, Definition, and Security. The SQL tab displays the SQL code generated by dialog selections.

Does PostgreSQL support sequence?

A sequence in PostgreSQL is a user-defined schema-bound object that yields a sequence of integers based on a specified specification. The CREATE SEQUENCE statement is used to create sequences in PostgreSQL. Now let's analyze the above syntax: First, set the name of the sequence after the CREATE SEQUENCE clause.


1 Answers

Apache Derby Doc says: Use a NEXT VALUE FOR expression

Should be something like

SELECT NEXT VALUE FOR SAMPLE_SEQ;
like image 123
Andreas Dolk Avatar answered Oct 21 '22 10:10

Andreas Dolk