Discussion:
[firebird-support] [FB3] Inserting into a table with only an identity column
tvdien@ymail.com [firebird-support]
2016-12-13 21:05:29 UTC
Permalink
If I have a table like this:


CREATE TABLE EXAMPLE (
E_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY

);


How do I add a record to it, getting an automatically assigned ID?


For example, in PostgreSQL, I'd write:


INSERT INTO EXAMPLE(E_ID) VALUES (DEFAULT);


I know such a table doesn't seem very useful, but still...


Thanks!
Mark Rotteveel mark@lawinegevaar.nl [firebird-support]
2016-12-13 21:50:01 UTC
Permalink
Post by ***@ymail.com [firebird-support]
CREATE TABLE EXAMPLE (
E_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
);
How do I add a record to it, getting an automatically assigned ID?
&nbsp ; INSERT INTO EXAMPLE(E_ID) VALUES (DEFAULT);
I know such a table doesn't seem very useful, but still...
Just like in Firebird 2.1 and 2.5, using the SQL standard:

INSERT INTO example DEFAULT VALUES

See
http://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-dml-insert.html#fblangref25-dml-insert-defaults

Mark
tvdien@ymail.com [firebird-support]
2016-12-13 23:00:05 UTC
Permalink
Missed that; dank je. :)

Loading...