On Aug 30, 7:24 am, "Thomas Mueller" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> > Why is there not some "alias" for the H2 generated sequence
> > that is created for an AUTO_INCREMENT PK column,
> > that i can use in NEXTVAL()?
>
> Is there something like this in another database? In H2,
> auto-increment columns use a sequence, and you could query the
> sequence directly, but that is also non-standard.
>
> You could create a sequence of course.
>
> Regards,
> Thomas

Indeed, i COULD create a sequence myself, but since
AUTO_INCREMENT is a super standard (vs SQL 2003) extension
anyway, and the whole point of AUTO_INCREMENT in the first place
is that the database creates the sequence just so i don't have to
create
or manage it, it seem rather illogical NOT to have a way to reference
it
with a system generated alias, especially since sequences essentially
exist in their own namespace anyway (as they can only be referenced
in limited specific context's in SQL syntax) so it would not seem that
an auto generation of an alias would create a naming conflict with
explicit sequences with well a well chosen prefix, say "AUTO_" or
some such.

AUTO_INCREMENT also is implemented to account for the
fact that a PK column can be INT, or SMALLINT (i use both) as
well as  BIGINT/IDENTITY and so i don't have to deal with the
type conflicts in my java code due to an explicit sequence returning
Long objects for a Short key, etc, etc.  I.E. the great value of
AUTO_INCREMENT is ease of use for the (me) the programmer.

Using the excuse "what other DB's" do with this non-standard extension
seems, IMHO, irrelevant, and if H2 shows how complete support
for AUTO_INCREMENT can be done and the ease of use it adds to SQL
programming, perhaps that will lead to your design becoming the
standard (likely due to imitation by others); which would be promoted
by documenting this as an "ease of use" feature, so as to highlight
how it
simplifies the java code.

IMHO, AUTO_INCREMENT is better that explicit sequences because
of  "locality" of the syntax within CREATE TABLE definition, which
makes
the table definition more self documenting when reading it later ( i
guess
i have spent too much time maintaining code written by myself/
others).

Perhaps you might consider adding alternate syntax of
AUTO_INCREMENT[('sequencename')], which would essentially allow
creation of a sequence within the create table, but still retain the
benefit
of not having to deal with the type differences of a explicit
sequence.

regards,  John


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to