Subject | autoincrement fields |
---|---|
Author | paulruizendaal |
Post date | 2006-10-28T15:19:26Z |
I just noticed that postgres has a nifty, practical way to help
people migrating from systems with autoincrement fields:
<quote>
Symptom/Question - How do I create a serial/auto-incrementing field?
Answer -
PostgreSQL supports a SERIAL data type. It auto-creates a sequence.
For example, this:
CREATE TABLE person (
id SERIAL,
name TEXT
);
is automatically translated into this:
CREATE SEQUENCE person_id_seq;
CREATE TABLE person (
id INT4 NOT NULL DEFAULT nextval('person_id_seq'),
name TEXT
);
CREATE SEQUENCE will enter a new sequence number generator into the
current data base. This involves creating and initializing a new
single-row table with the name seqname. The generator will be "owned"
by the user issuing the command.
</quote>
Would there be any issues with doing the same for Firebird?
Paul
people migrating from systems with autoincrement fields:
<quote>
Symptom/Question - How do I create a serial/auto-incrementing field?
Answer -
PostgreSQL supports a SERIAL data type. It auto-creates a sequence.
For example, this:
CREATE TABLE person (
id SERIAL,
name TEXT
);
is automatically translated into this:
CREATE SEQUENCE person_id_seq;
CREATE TABLE person (
id INT4 NOT NULL DEFAULT nextval('person_id_seq'),
name TEXT
);
CREATE SEQUENCE will enter a new sequence number generator into the
current data base. This involves creating and initializing a new
single-row table with the name seqname. The generator will be "owned"
by the user issuing the command.
</quote>
Would there be any issues with doing the same for Firebird?
Paul