sequence's name

63 views
Skip to first unread message

PatMac

unread,
Oct 21, 2008, 5:43:32 PM10/21/08
to H2 Database
Hi,

Is there a way to get the name of a sequence (or to force it when
creating the table) for an identity column? When we create a table
with an identity column, the sequence gets a unique name that cannot
be discovered it seems.

Thanks,

Thomas Mueller

unread,
Oct 23, 2008, 12:11:26 AM10/23/08
to h2-da...@googlegroups.com
Hi,

CREATE SEQUENCE TESTSEQ;
CREATE TABLE TEST(ID INT DEFAULT NEXT VALUE FOR TESTSEQ PRIMARY KEY);

There is a way to get the sequence name, but it is complicated.
Basically you need to parse COLUMN_DEFAULT in:
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT FROM
INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_DEFAULT IS NOT NULL;

Regards,
Thomas

PatMac

unread,
Oct 23, 2008, 8:24:14 AM10/23/08
to H2 Database
Hi Thomas,

I had already looked to parse... but as you said, it is complicated. I
will use the first option. Thanks.

Patrice

On 23 oct, 00:11, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages